Ok, I've beat my head against this for an hour. I may be on crack, and just missing something simple. Please let me know if that's the case.
This little number is supposed to read a file and return only the lines that do not contain the string 'fubar'.
sysopen (FILE,$filename,O_RDONLY) or die "Error! $!\n";
my (@slurp) = <FILE>;
close FILE;
foreach my $foo (@slurp) { unless ($foo =~ /fubar/i) {print $foo; } }
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;
my (@lines) = grep !/fubar/, @slurp;
foreach my $foo (@lines) { 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.
TIA
"Non sequitur. Your facts are un-coordinated." - Nomad