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

if (my $x = do {my $x = f(); $x and g($x)}) { print "cheerful: $x\n"; }

Replies are listed 'Best First'.
Re^4: scope of my $x in if statements
by shmem (Chancellor) on May 07, 2009 at 22:35 UTC

    Yes, that works with subroutine return, and subs that modify their arguments.

    sub g { $_[0] = "ikegami++" } ... __END__ cheerful: ikegami++