my $x = 'foo'; my $y = 'The answer is $x'; my $z = eval enquote($y); sub enquote { return 'qq{' . shift() . '}'; }