in reply to Re^2: Ignoring lines in flat text file
in thread Ignoring lines in flat text file
The entire expression must be in parens.
You also have logic errors. Your expression will always be true.
if ( $line !~ m/^2/ || ( substr($line, 14, 3) ne '800' && substr($line, 14, 3) ne '866' && substr($line, 14, 3) ne '877' && substr($line, 14, 3) ne '888' ) ) { ... }
That could be simplified using a regexp or a lookup table
if ( $line !~ m/^2/ || substr($line, 14, 3) !~ /^(?:800|866|877|888)\z/ ) { ... }
my %tollfree = map { $_ => 1 } 800, 866, 877, 888; if ( $line !~ m/^2/ || !$tollfree{ substr($line, 14, 3) } ) { ... }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Ignoring lines in flat text file
by sheasbys (Initiate) on Sep 11, 2007 at 16:47 UTC | |
by ikegami (Patriarch) on Sep 11, 2007 at 18:38 UTC | |
|