http://qs1969.pair.com?node_id=540363


in reply to Re: Simple regexp question
in thread Simple regexp question

We get the following:

open(local *INFILE, '<', $filename) or die("Unable to open the input file: $!\n"); my @filtered; while (<INFILE>) { push(@filtered, $_) unless /[#*]/; } print @filtered;

What follows is a more elegant but more memory intensive alternative:

open(local *INFILE, '<', $filename) or die("Unable to open the input file: $!\n"); my @filtered = grep { !/[#*]/ } <INFILE>; print @filtered;