it's probably just me
"John DePasquale" <[email protected]> Wed, 28 Oct 2015 11:13:12 -0400
| Newsgroups | gmane.comp.lang.perl.active-perl |
|---|---|
| Message-ID | <[email protected]> |
This is a multipart message in MIME format.
--===============1977996518==
Content-Type: multipart/alternative;
boundary="----=_NextPart_000_01BD_01D11171.A3454EA0"
Content-Language: en-us
This is a multipart message in MIME format.
------=_NextPart_000_01BD_01D11171.A3454EA0
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
Hi perl mavens,
I'm sure I just don't understand something here, but this one makes zero
sense to me:
The following snippet prints a 1
local @aList;
push @aList, ['first','second','third'];
my $nCount = @aList;
print "count: $nCount";
BUT, if I add one seemingly irrelevant line ( the second one below ),
something crazy happens:
local @aList;
print "non-existent value: $aList[0][0]\n";
push @aList, ['first','second','third'];
my $nCount = @aList;
print "count: $nCount";
instead of printing a 1, the last line prints a 2
So the reference in the first print statement to $aList[0][0] appears to
have the affect of creating a row in the array.
Is this supposed to work this way? Why would such a reference to a
non-existent array row result in the creation of an array row?
Thank you.
- john
John DePasquale
Chief Executive Officer
Paradigm Consulting
"Proudly presenting the Vinopedia System"
www.vinopedia.us <http://www.vinopedia.us/>
49 Dalby Street
Newton, MA 02458
Mobile: 617-610-2424
Fax: 617-600-7326
_____
------=_NextPart_000_01BD_01D11171.A3454EA0
Content-Type: text/html;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
<html xmlns:v=3D"urn:schemas-microsoft-com:vml" =
xmlns:o=3D"urn:schemas-microsoft-com:office:office" =
xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" =
xmlns=3D"http://www.w3.org/TR/REC-html40"><head><meta =
http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dus-ascii"><meta name=3DGenerator content=3D"Microsoft Word 14 =
(filtered medium)"><!--[if !mso]><style>v\:* =
{behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Verdana;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{mso-style-priority:34;
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
span.EmailStyle18
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:windowtext;}
span.EmailStyle19
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.EmailStyle20
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
/* List Definitions */
@list l0
{mso-list-id:1142113423;
mso-list-type:hybrid;
mso-list-template-ids:371503634 -864891428 67698691 67698693 67698689 =
67698691 67698693 67698689 67698691 67698693;}
@list l0:level1
{mso-level-start-at:0;
mso-level-number-format:bullet;
mso-level-text:-;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:20.25pt;
text-indent:-.25in;
font-family:"Calibri","sans-serif";
mso-fareast-font-family:Calibri;
mso-bidi-font-family:"Times New Roman";}
@list l0:level2
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:56.25pt;
text-indent:-.25in;
font-family:"Courier New";}
@list l0:level3
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:92.25pt;
text-indent:-.25in;
font-family:Wingdings;}
@list l0:level4
{mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:128.25pt;
text-indent:-.25in;
font-family:Symbol;}
@list l0:level5
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:164.25pt;
text-indent:-.25in;
font-family:"Courier New";}
@list l0:level6
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:200.25pt;
text-indent:-.25in;
font-family:Wingdings;}
@list l0:level7
{mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:236.25pt;
text-indent:-.25in;
font-family:Symbol;}
@list l0:level8
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:272.25pt;
text-indent:-.25in;
font-family:"Courier New";}
@list l0:level9
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:308.25pt;
text-indent:-.25in;
font-family:Wingdings;}
@list l1
{mso-list-id:1505630137;
mso-list-type:hybrid;
mso-list-template-ids:288397876 455528034 67698691 67698693 67698689 =
67698691 67698693 67698689 67698691 67698693;}
@list l1:level1
{mso-level-start-at:0;
mso-level-number-format:bullet;
mso-level-text:-;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;
font-family:"Calibri","sans-serif";
mso-fareast-font-family:Calibri;
mso-bidi-font-family:"Times New Roman";}
@list l1:level2
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;
font-family:"Courier New";}
@list l1:level3
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;
font-family:Wingdings;}
@list l1:level4
{mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;
font-family:Symbol;}
@list l1:level5
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;
font-family:"Courier New";}
@list l1:level6
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;
font-family:Wingdings;}
@list l1:level7
{mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;
font-family:Symbol;}
@list l1:level8
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;
font-family:"Courier New";}
@list l1:level9
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;
font-family:Wingdings;}
ol
{margin-bottom:0in;}
ul
{margin-bottom:0in;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]--></head><body lang=3DEN-US link=3Dblue =
vlink=3Dpurple><div class=3DWordSection1><p class=3DMsoNormal><span =
style=3D'color:#1F497D'>Hi perl mavens,<o:p></o:p></span></p><p =
class=3DMsoNormal><span style=3D'color:#1F497D'>I’m sure I just =
don’t understand something here, but this one makes zero sense to =
me:<o:p></o:p></span></p><p class=3DMsoNormal><span =
style=3D'color:#1F497D'>The following snippet prints a =
1<o:p></o:p></span></p><p class=3DMsoNormal><span =
style=3D'color:#1F497D'> &=
nbsp; local =
@aList;<o:p></o:p></span></p><p class=3DMsoNormal><span =
style=3D'color:#1F497D'> &=
nbsp; push @aList, =
['first','second','third'];<o:p></o:p></span></p><p =
class=3DMsoNormal><span =
style=3D'color:#1F497D'> &=
nbsp; my $nCount =3D =
@aList;<o:p></o:p></span></p><p class=3DMsoNormal><span =
style=3D'color:#1F497D'> &=
nbsp; print "count: =
$nCount";<o:p></o:p></span></p><p class=3DMsoNormal><span =
style=3D'color:#1F497D'><o:p> </o:p></span></p><p =
class=3DMsoNormal><span style=3D'color:#1F497D'>BUT, if I add one =
seemingly irrelevant line ( the second one below ), something crazy =
happens:<o:p></o:p></span></p><p class=3DMsoNormal><span =
style=3D'color:#1F497D'> &=
nbsp; local =
@aList;<o:p></o:p></span></p><p class=3DMsoNormal><span =
style=3D'color:#1F497D'> &=
nbsp; print "non-existent =
value: $aList[0][0]\n";<o:p></o:p></span></p><p =
class=3DMsoNormal><span =
style=3D'color:#1F497D'> &=
nbsp; push @aList, =
['first','second','third'];<o:p></o:p></span></p><p =
class=3DMsoNormal><span =
style=3D'color:#1F497D'> &=
nbsp; my $nCount =3D =
@aList;<o:p></o:p></span></p><p class=3DMsoNormal><span =
style=3D'color:#1F497D'> &=
nbsp; print "count: =
$nCount";<o:p></o:p></span></p><p class=3DMsoNormal><span =
style=3D'color:#1F497D'><o:p> </o:p></span></p><p =
class=3DMsoNormal><span style=3D'color:#1F497D'>instead of printing a 1, =
the last line prints a 2<o:p></o:p></span></p><p class=3DMsoNormal><span =
style=3D'color:#1F497D'>So the reference in the first print statement to =
$aList[0][0] appears to have the affect of creating a row in the =
array.<o:p></o:p></span></p><p class=3DMsoNormal><span =
style=3D'color:#1F497D'>Is this supposed to work this way? Why would =
such a reference to a non-existent array row result in the creation of =
an array row?<o:p></o:p></span></p><p class=3DMsoNormal><span =
style=3D'color:#1F497D'>Thank you.<o:p></o:p></span></p><p =
class=3DMsoListParagraph =
style=3D'margin-left:20.25pt;text-indent:-.25in;mso-list:l0 level1 =
lfo3'><![if !supportLists]><span style=3D'color:#1F497D'><span =
style=3D'mso-list:Ignore'>-<span style=3D'font:7.0pt "Times New =
Roman"'> =
</span></span></span><![endif]><span =
style=3D'color:#1F497D'>john<o:p></o:p></span></p><p =
class=3DMsoNormal><span =
style=3D'color:#1F497D'><o:p> </o:p></span></p><div><p =
class=3DMsoNormal><span style=3D'color:#1F497D'>John =
DePasquale<o:p></o:p></span></p><p class=3DMsoNormal><span =
style=3D'color:#1F497D'>Chief Executive Officer<o:p></o:p></span></p><p =
class=3DMsoNormal><span style=3D'color:#1F497D'>Paradigm =
Consulting<o:p></o:p></span></p><p class=3DMsoNormal><i><span =
style=3D'color:#1F497D'>“Proudly presenting the Vinopedia =
System”<o:p></o:p></span></i></p><p class=3DMsoNormal><span =
style=3D'color:#1F497D'><a =
href=3D"http://www.vinopedia.us/">www.vinopedia.us</a><o:p></o:p></span><=
/p><p class=3DMsoNormal><span style=3D'color:#1F497D'>49 Dalby =
Street<o:p></o:p></span></p><p class=3DMsoNormal><span =
style=3D'color:#1F497D'>Newton, MA 02458<o:p></o:p></span></p><p =
class=3DMsoNormal><span style=3D'color:#1F497D'>Mobile: =
617-610-2424<o:p></o:p></span></p><p class=3DMsoNormal><span =
style=3D'color:#1F497D'>Fax: 617-600-7326</span><span =
style=3D'font-family:"Verdana","sans-serif";color:#1F497D'><o:p></o:p></s=
pan></p><div class=3DMsoNormal align=3Dcenter =
style=3D'text-align:center'><span =
style=3D'font-family:"Verdana","sans-serif";color:#1F497D'><hr size=3D2 =
width=3D"100%" align=3Dcenter></span></div></div></div></body></html>
------=_NextPart_000_01BD_01D11171.A3454EA0--
--===============1977996518==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============1977996518==--