tab@music3:~/2018-0717$ cat pm.pl #!/usr/bin/perl use strict; use warnings; { my $word = '$-.%'; my $new_word = join ( '', map { "[$_]" } split /[a-zA-Z]/, $word ); print "$word -> $new_word\n"; } tab@music3:~/2018-0717$ perl pm.pl $-.% -> [$-.%] tab@music3:~/2018-0717$