| Store | Cart

it's probably just me

From: John DePasquale <joh...@johndepasquale.net>
Wed, 28 Oct 2015 11:13:12 -0400
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
Acti...@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Recent Messages in this Thread
John DePasquale Oct 28, 2015 03:13 pm
JONES, ROBERT E CTR USAF AETC AETC/A5TP Oct 28, 2015 03:20 pm
Francisco Zarabozo Oct 28, 2015 03:48 pm
John DePasquale Oct 28, 2015 04:17 pm
Francisco Zarabozo Oct 28, 2015 04:33 pm
nonlin Oct 28, 2015 05:57 pm
Messages in this thread