$ perl -wE' sub f { local our $x = $_[0]; "" =~ /(??{ say $x; "" })/; } f("abc"); f("def"); ' abc def