foreach my $line (@array) { next if ($line =~ /^#/); push @new, $line; }