in reply to Re: A perverse use of grep
in thread A perverse use of grep

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