use strict; use warnings; use 5.010; my $x = 10; my $result = sprintf '%s', 'my $y = $x;'; say $result; --output:-- my $y = $x;