in reply to A perverse use of grep

How would you do it?

On 8 lines instead of 1 :-(

while (<$f>){ chomp; s/^\s+//; s/\s+$//; next unless length; next if /^#/; push @lines, $_; }

Replies are listed 'Best First'.
Re^2: A perverse use of grep
by QM (Parson) on Jun 15, 2005 at 20:41 UTC
    Don't do all that work, and then throw it away -- put the next if /^#/; first:
    while (<$f>){ next if /^#/; chomp; s/^\s+//; s/\s+$//; next unless length; push @lines, $_; }

    -QM
    --
    Quantum Mechanics: The dreams stuff is made of