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 behaves similar to for in this respect.if ( my $t = shift ) { $t =~ s/change_something/to_something_else/; } print "$t\n"; # out of scope here
Somewhat surprisingly then, this does not work:
print $t if (my $t = shift);
In Section
Seekers of Perl Wisdom