Can you explain it?

O

Oliver Block

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
 
X

xhoster

Oliver Block said:
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
 
A

Anno Siegel

Oliver Block said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,266
Messages
2,571,075
Members
48,772
Latest member
Backspace Studios

Latest Threads

Top