my $string = 'print "foo"'; $string =~ s/(print)\s*("\w+")/\$lang->$1($2, \$currentUser->lang() )/g; print $string;