If you're creating an array you should use parenthesis ().

Robert Jones, BSP, BSCS
TTMS Project Interfaces
Keesler AFB

-----Original Message-----
From: activeperl-boun...@listserv.activestate.com 
[mailto:activeperl-boun...@listserv.activestate.com] On Behalf Of John 
DePasquale
Sent: Wednesday, October 28, 2015 10:13 AM
To: activeperl@listserv.ActiveState.com
Subject: it's probably just me

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

________________________________

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to