Is this a bug, undefined behaviour or just a general lack of wakefulness on my behalf
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
So the strange thing there is that when the bare block scope is re-entered the
POK and
pPOK flags have been removed (which indicate the validity of a variable and the validity of the variable in regards to the magic system, respectively) but the original value remains. Whereas the subroutine doesn't have any problems (as would be expected). Anyone have an idea as to why this is happening?
HTH
_________
broquaint
512 posts later and I'm still asking questions, ain't perl (and of course Perlmonks!) great?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.