in reply to Re^3: Ignoring lines in flat text file
in thread Ignoring lines in flat text file

When I use this code, without your suggestions, I preserve the contents of any line starting with a "2," which is desirable:

if ( $line !~ m/^2/ ) { . . . else { print OUTPUT $line . "\n";

My goal is to preserve any line starting with a 2 and write it to output as well as writing any line where positions 14-16 are not 800, 866, 877 or 888. While the logic appears sound to me it does not make sense why these lines are not written to the output.

BTW I really appreciate your help.

Replies are listed 'Best First'.
Re^5: Ignoring lines in flat text file
by ikegami (Patriarch) on Sep 11, 2007 at 18:38 UTC

    I guess I understood a little backwards earlier.

    my %tollfree = map { $_ => 1 } 800, 866, 877, 888; if ( $line =~ m/^2/ || !$tollfree{ substr($line, 14, 3) } ) { print OUTPUT "$line\n"; } else { ... }
    A reply falls below the community's threshold of quality. You may see it by logging in.