http://www.perlmonks.org?node_id=656376


in reply to Re: Duh. 'my' scope in if else blocks.
in thread Duh. 'my' scope in if else blocks.

This won't work either, even though my $t is outside of the curlies (but inside the parens) now:
if ( my $t = shift ) { $t =~ s/change_something/to_something_else/; } print "$t\n"; # out of scope here
if behaves similar to for in this respect.

Somewhat surprisingly then, this does not work:

print $t if (my $t = shift);