On Jan 3, Booher Timothy B 1stLt AFRL/MNAC said:
>next if $line =~ (/^\*+/)|(/^\s*$/);
Wow. The reason that appears to work is a bizarre one indeed.
while (<FOO>) {
$line = $_;
next if $line =~ (/foo/) | (/bar/);
# ...
}
That code is the as
while (<FOO>) {
$line = $_;
next if ($line =~ /foo/) | ($_ =~ /bar/);
# ...
}
The reason that returns true is because both $line and $_ are the same
string. Safe to say, you have been saved by bizarre coincidence.
Consider yourself lucky.
>and it seems to work, but you say: next if $line =~ /^(\*|\s*$)/; wouldn't
>this only find one "*" that the line starts with.
The regex /^a/ and the regex /^a+/ are, for your purpose, the same
thing. If a string matches /^a+/, it HAS to ALSO match /^a/.
>* foo
>************************ foo
>
>would both be skipped
Yes. Both begin with a '*'. The fact that the second happens to have a
lot more '*'s after the first one is not important.
>what about $line =~ /^(\**|\s*$)/;
No, because /\**/ matches ZERO or more stars, and every line matches that.
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]