$foo = "hello"; my $x = "$foo%s"; my $output = sprintf $x, $y; # replaces "%s" with $y print $output;