in reply to Re: scope of my $x in if statements
in thread scope of my $x in if statements

Clobbering your caller's $_ is bad (even in everyday scenarios), so you need to add local. When you do, you end up with the same problem and nothing is solved.