# surround all uppercase characters in the passed parameter with *'s # and all lowercase characters with _'s # (modifies parameter in-place) sub transmogrify { my $string = $_[0]; $string =~ s/([A-Z])/*$1*/g; $string =~ s/([a-z])/_$1_/g; $_[0] = $string; return; } $text = "I met this guy, and he looked like he might have been a hat check clerk at an ice rink, which in fact, he turned out to be. Let X = X."; transmogrify($text); print $text;