Clownburner has asked for the wisdom of the Perl Monks concerning the following question:
It returns all the lines, even the ones with 'fubar' in them. I've tried using /ig instead of just /i, no change. I have also tried this:sysopen (FILE,$filename,O_RDONLY) or die "Error! $!\n"; my (@slurp) = <FILE>; close FILE; foreach my $foo (@slurp) { unless ($foo =~ /fubar/i) {print $foo; } }
That didn't work either. When I reversed the grep (changed it to print only lines that matched), nothing printed at all. So it's the grep / match that's failing. The 'fubar' string is in the text, and it's not specially hidden - in fact it's padded with white space. So, what the heck is wrong here? What am I doing wrong? If it's relevant, I'm running perl, version 5.005_03. TIAsysopen (FILE,$filename,O_RDONLY) or die "Error! $!\n"; my (@slurp) = <FILE>; close FILE; my (@lines) = grep !/fubar/, @slurp; foreach my $foo (@lines) { print $foo; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Strange grep and matching behaviour...
by Ovid (Cardinal) on May 22, 2002 at 21:24 UTC | |
Re: Strange grep and matching behaviour...
by virtualsue (Vicar) on May 22, 2002 at 21:28 UTC | |
Re: Strange grep and matching behaviour...
by buckaduck (Chaplain) on May 22, 2002 at 21:26 UTC | |
by graff (Chancellor) on May 22, 2002 at 22:20 UTC | |
Re: Strange grep and matching behaviour...
by vladb (Vicar) on May 22, 2002 at 21:27 UTC |