J
Jim Cochrane
Thanks, Jim. Missing semicolons were the culprit:
#!/usr/bin/perl -w
use strict;
use warnings;
my $killrc = "sample.killrc";
my @filter;
my @list1 = qw( Mon Tu Wed);
open(FILE, "<$killrc") and do {
@filter = ();
foreach (<FILE>) {
chomp; length or next; /^#/o and next;
my $pat; eval '$pat = qr/$_/' or do {prompt $@; next};
push @filter, $pat;
};
close(FILE);
};
print @filter;
print @list1;
# perl mats5.pl 2>text50.txt >text51.txt
__END__
#end script begin output
(?-xism:^From:.*<[email protected]>)(?-xism:^Subject:.*MONEY)(?-xism:^Message-ID:.*googlegroups)MonTuWed
#end output show sample.killrc
^From:.*<[email protected]>
^Subject:.*MONEY
^Message-ID:.*googlegroups
Any ideas where the ?-xism is coming from?
I beg to differ. I snipped this from an actual, working perl program. How
do you know which braces need a semicolon after?
If I remember correctly, line 18 (from your error message) was either
the offending line with the close curly brace missing the ';' or the
line (print ...) below it. So you know where to look because of the
line # in the error message. Of course, now that you know that 'do {}'
blocks need a semicolon after them (right?), you know to look for that
now, too. (Of course, compile error messages will not always report a
line number that is at or very close to the actual problem in the code.)
sub read_killrc {
open(FILE, "<$killrc") and do {
@filter = ();
foreach (<FILE>) {
chomp; length or next; /^#/o and next;
my $pat; eval '$pat = qr/$_/' or do {prompt $@; next};
push @filter, $pat;
}
close(FILE);
};
}
The error had nothing to do with the print statements, but with a missing
token several lines before. At least now I've got output, so I can waddle
along.
--