I don't understand the effort to use split and map in solutions. Even with this latest version of the assumed implied requirement, a good, old s/// seems the best way:
c:\@Work\Perl\monks>perl -wMstrict -le "my $word = '$-.%aBc&/d-E'; ;; (my $new_word = $word) =~ s{ ([^[:alpha:]]+ | [[:alpha:]]) }{[$1]}xms +g; ;; print qq{'$word' -> '$new_word'}; " '$-.%aBc&/d-E' -> '[$-.%][a][B][c][&/][d][-][E]'
Give a man a fish: <%-{-{-{-<
In reply to Re^8: regex find and replace with a twist
by AnomalousMonk
in thread regex find and replace with a twist
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |