use strict; my $foo = "bar"; my $test = sub { my $string = "$foo out"; $string =~ s/b/f/; return $string }; print &$test,"\n";