in reply to Regex negative lookahead
"The NEXT thing cannot be ".pl". When it sees text ending in ".pl", the thing AFTER the ".pl is NOT ".pl", it is the end of line. So, the match succeeds.
The problem is that it is a ZERO WIDTH assertion, and does not require any text to match.
I would write the expression as :
Which works fine.print "$file\n" if $file !~/\.pl$/
If you want to avoid the "." and "..", you need to check for those :
next if $file =~/^\.\.?$|\.pl$/;
What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?
-Larry Wall, 1992
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regex negative lookahead
by aeqr (Novice) on Apr 25, 2014 at 04:35 UTC | |
by NetWallah (Canon) on Apr 25, 2014 at 04:39 UTC | |
by mr_mischief (Monsignor) on Apr 25, 2014 at 14:16 UTC |