in reply to regex find and replace with a twist

Heres a short example that does that:

use strict; use warnings; my $modified_string; while ( read DATA, my $buf, 1 ) { $modified_string .= "[$buf]" unless $buf !~ /[a-zA-Z]/; } print $modified_string; __DATA__ this is a test

And yet another example!:

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

EDIT: changed pattern match to include only characters a-z in first example.