broquaint has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use warnings; use Devel::Peek; my $i = 0; { my $x = "foo"; sub bbtest { $x .= " bar"; print "subroutine: ", $x, $/; } } { my $x = "foo"; SUB_BBTEST: { Dump($x); $x .= " bar"; print "bareblock : ", $x, $/; } } goto SUB_BBTEST while $i++ < 3; bbtest() while $i++ < 7;
__output__ SV = PV(0x80fbe38) at 0x8108048 REFCNT = 1 FLAGS = (PADBUSY,PADMY,POK,pPOK) PV = 0x8101be0 "foo"\0 CUR = 3 LEN = 4 bareblock : foo bar SV = PV(0x80fbe38) at 0x8108048 REFCNT = 1 FLAGS = (PADBUSY,PADMY) PV = 0x8101be0 "foo bar"\0 CUR = 7 LEN = 8 bareblock : bar SV = PV(0x80fbe38) at 0x8108048 REFCNT = 1 FLAGS = (PADBUSY,PADMY,POK,pPOK) PV = 0x8101be0 " bar"\0 CUR = 4 LEN = 8 bareblock : bar bar SV = PV(0x80fbe38) at 0x8108048 REFCNT = 1 FLAGS = (PADBUSY,PADMY,POK,pPOK) PV = 0x8101be0 " bar bar"\0 CUR = 8 LEN = 9 bareblock : bar bar bar subroutine: foo bar subroutine: foo bar bar subroutine: foo bar bar bar
_________
broquaint
512 posts later and I'm still asking questions, ain't perl (and of course Perlmonks!) great?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Bare blocks forgetting lexical values
by sauoq (Abbot) on Dec 05, 2002 at 18:33 UTC | |
|
Re: Bare blocks forgetting lexical values
by BrowserUk (Patriarch) on Dec 05, 2002 at 19:36 UTC | |
|
Re: Bare blocks forgetting lexical values
by shotgunefx (Parson) on Dec 05, 2002 at 20:53 UTC | |
by Elian (Parson) on Dec 17, 2002 at 22:15 UTC | |
by shotgunefx (Parson) on Dec 17, 2002 at 22:57 UTC |