in reply to Re^2: if(my) scope
in thread if(my) scope

You changed
if (my $var) { ... }
to
if (...) { my $var; ... }
use strict; use warnings; use Devel::Peek; my $ref; if ((my $fred = 42), 1) { $ref = \$fred; Dump($$ref); } Dump($$ref);
SV = IV(0x816a5cc) at 0x814f684 REFCNT = 2 FLAGS = (PADBUSY,PADMY,IOK,pIOK) IV = 42 SV = IV(0x816a5cc) at 0x814f684 REFCNT = 2 FLAGS = (PADBUSY,PADMY,IOK,pIOK) IV = 42

A scope is created for if's curlies, but only a compile-time scope is created for the condition expression.

Btw, note the proper usage of Dump.

Replies are listed 'Best First'.
Re^4: if(my) scope
by cdarke (Prior) on Apr 16, 2009 at 16:01 UTC
    Doh!