foreach my $item (@array) { $item =~ s/\W//g; # Remove non-word characters $item =~ s/_//g; # Remove all underscores }