McMahon has asked for the wisdom of the Perl Monks concerning the following question:
If <STRINGFILE> has something in it, everything works fine. But if STRINGFILE isn't specified, @strings is null. I did not expect ($file1 =~ $string) to always be true if the right side of the expression is null.my @strings; my $stringFile = <STDIN>; chomp $stringFile; if ($stringFile eq "") { print "No file of exclude strings specified.\n"; } else { open (STRINGFILE, "$stringFile") or die "Couldn't open $stringFile:$!\n"; @strings = <STRINGFILE>; } #BLAH BLAH BLAH foreach my $file1(@file1only) { foreach my $string(@strings) { chomp $string; unless ($file1 =~ $string) { print OUT $file1; last; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Help with null string behavior in regex?
by hv (Prior) on May 03, 2004 at 22:03 UTC | |
by McMahon (Chaplain) on May 03, 2004 at 22:45 UTC | |
by Eimi Metamorphoumai (Deacon) on May 04, 2004 at 19:34 UTC | |
|
Re: Help with null string behavior in regex?
by diotalevi (Canon) on May 03, 2004 at 21:40 UTC | |
by McMahon (Chaplain) on May 03, 2004 at 21:51 UTC | |
by diotalevi (Canon) on May 03, 2004 at 22:58 UTC | |
by McMahon (Chaplain) on May 03, 2004 at 23:53 UTC | |
by diotalevi (Canon) on May 04, 2004 at 00:06 UTC | |
|
Re: Help with null string behavior in regex?
by Belgarion (Chaplain) on May 03, 2004 at 21:34 UTC |