I did not know to use the return value of `do' back in the day.
There's probably no practical difference in these cases, but
`eval' is overkill for these uses and may hide actual errors.
We can get rid of a few redundant `scalar' ops and pass scalar
refs to Email::MIME->new to avoid copies in a few more places,
too.
my $spamc = PublicInbox::Spamcheck::Spamc->new;
my $pi_config = PublicInbox::Config->new;
my $err;
-my $mime = PublicInbox::MIME->new(eval {
+my $mime = PublicInbox::MIME->new(do{
local $/;
- my $data = scalar <STDIN>;
+ my $data = <STDIN>;
$data =~ s/\A[\r\n]*From [^\r\n]*\r?\n//s;
if ($train ne 'rm') {
};
$err = $@;
}
- $data
+ \$data
});
sub remove_or_add ($$$$) {
# in case there's bugs in our code or user error.
my $emergency = $ENV{PI_EMERGENCY} || "$ENV{HOME}/.public-inbox/emergency/";
$ems = PublicInbox::Emergency->new($emergency);
-my $str = eval { local $/; <STDIN> };
+my $str = do { local $/; <STDIN> };
$str =~ s/\A[\r\n]*From [^\r\n]*\r?\n//s;
$ems->prepare(\$str);
my $simple = Email::Simple->new(\$str);
my @ibxs = PublicInbox::Admin::resolve_inboxes(\@ARGV, $opt);
PublicInbox::AdminEdit::check_editable(\@ibxs);
-my $data = do { local $/; scalar <STDIN> };
+my $data = do { local $/; <STDIN> };
$data =~ s/\A[\r\n]*From [^\r\n]*\r?\n//s;
my $n_purged = 0;
foreach my $sub (qw(cur new)) {
foreach my $fn (glob("$dir/$sub/*")) {
open my $fh, '<', $fn or next;
- my $s = Email::Simple->new(eval { local $/; <$fh> });
+ my $s = Email::Simple->new(do { local $/; <$fh> });
my $date = $s->header('Date');
my $t = eval { str2time($date) };
defined $t or next;
while (my $ary = pop @msgs) {
my $fn = "$dir/$ary->[1]";
open my $fh, '<', $fn or next;
- my $mime = PublicInbox::MIME->new(eval { local $/; <$fh> });
+ my $mime = PublicInbox::MIME->new(do { local $/; <$fh> });
$im->add($mime);
}
$im->done;
$max = $n + $max_gap;
print STDERR $fn, "\n";
- my $mime = PublicInbox::MIME->new(eval { local $/; <$fh> });
+ my $mime = PublicInbox::MIME->new(do { local $/; <$fh> });
$filter->scrub($mime);
$im->add($mime);
foreach my $n (grep(/\d+\z/, glob("$spool/*"))) {
if (open my $fh, '<', $n) {
- my $f = Email::Filter->new(data => eval { local $/; <$fh> });
+ my $f = Email::Filter->new(data => do { local $/; <$fh> });
my $s = $f->simple;
# gmane rewrites Received headers, which increases spamminess
use URI::Escape qw/uri_escape_utf8/;
use File::Temp qw/tempfile/;
my ($fh, $filename) = tempfile('ssoma-replay-XXXXXXXX', TMPDIR => 1);
-my $msg = eval {
- local $/;
- Email::Simple->new(<STDIN>);
-};
+my $msg = Email::Simple->new(do { local $/; <STDIN> });
select $fh;
# Note: the archive URL makes assumptions about where the
-primary_address => 'test@example.com',
indexlevel => 'full',
};
-my $agpl = eval {
+my $agpl = do {
open my $fh, '<', 'COPYING' or die "can't open COPYING: $!";
local $/;
<$fh>;
};
-$agpl or die "AGPL or die :P\n";
my $phrase = q("defending all users' freedom");
my $mime = PublicInbox::MIME->create(
header => [
{
my $patch = 't/data/0001.patch';
open my $fh, '<', $patch or die "failed to open $patch: $!\n";
- $msg = eval { local $/; <$fh> };
+ $msg = do { local $/; <$fh> };
PublicInbox::Emergency->new($maildir)->prepare(\$msg);
PublicInbox::WatchMaildir->new($config)->scan('full');
my ($nr, $msgs) = $srch->reopen->query('dfpost:6e006fd7');