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