$ perl -wE' sub f { my $x = $_[0]; "" =~ /(??{ say $x; "" })/; } f("abc"); f("def"); ' Variable "$x" will not stay shared at (re_eval 1) line 1. abc abc #### $ perl -wE' sub f { local our $x = $_[0]; "" =~ /(??{ say $x; "" })/; } f("abc"); f("def"); ' abc def