$bar = "Hello %s world!\n"; if ($bar =~ m/(Hello)/) { $foo = lc $1; $foo =~ s/h/j/; printf $bar, $foo; # prints "Hello jello world!" } #### $bar = "Hello $foo world!\n"; if ($bar =~ m/(Hello)/) { $foo = lc $1; $foo =~ s/h/j/; print "$foo\n"; # prints "jello" print $bar; # prints "Hello world!" }