For Programmers: Free Programming Magazines  


Home > Archive > PERL Miscellaneous > July 2005 > Can you explain it?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Can you explain it?
Oliver Block

2005-07-26, 5:02 pm

Hi,

do you have any idea, why the following construct increases the number
of element of my array of arrays @myArray with one?

if ( @#{ $myArray[$myElements] } < 0) { ...

bye,

Oliver

xhoster@gmail.com

2005-07-26, 5:02 pm

"Oliver Block" <oliver.block@epost.de> wrote:
> Hi,
>
> do you have any idea, why the following construct increases the number
> of element of my array of arrays @myArray with one?
>
> if ( @#{ $myArray[$myElements] } < 0) { ...


I don't know that it does do that (I couldn't replicate it), but I wonder
why you messing with a slice of the semi-special hash '%#'?

Did you perhaps mean $# rather than @#?

Are you using warnings?

Xho

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
Tad McClellan

2005-07-26, 10:03 pm

Oliver Block <oliver.block@epost.de> wrote:


> Subject: Can you explain it?



Please put the subject of your article in the Subject of your article.


--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
Anno Siegel

2005-07-27, 4:02 am

Oliver Block <oliver.block@epost.de> wrote in comp.lang.perl.misc:
> Hi,
>
> do you have any idea, why the following construct increases the number
> of element of my array of arrays @myArray with one?
>
> if ( @#{ $myArray[$myElements] } < 0) { ...


What a mess. Your subject tells us nothing about your question, your
code is messed up, and your question makes an unjustified assumption.

In truth, what you do doesn't increase the number of array elements by
one, it creates a new array element in position $myElements unless
there already is one. The reason for this happening is called
"autovivification". Read about it in perlref.

Anno
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com