use strict; use warnings; my $string = "this is a test"; my $modified_string = $string =~ s/([a-zA-Z])/\[$1\]/gr; print $modified_string;