H
Helmut Tessarek
I'm wondering how the $#array construct works internally.
Does perl iterate through the array and return the highest index or does perl
use some meta data within the array structure?
The reason why I ask is the following:
I need the number of elements in a certain array several times throughout my
code. I build the array at the beginning and after that it does not change
anymore.
So I can use a variable which I increment during the construction of the array
or I could use $#array+1 to get the number of elements.
I need the number of elements several times in my code, so if perl has to
iterate through the array every time I use $#array, it is better for
performance to use a separate variable which I increment while building the
array....
Cheers,
Helmut
Does perl iterate through the array and return the highest index or does perl
use some meta data within the array structure?
The reason why I ask is the following:
I need the number of elements in a certain array several times throughout my
code. I build the array at the beginning and after that it does not change
anymore.
So I can use a variable which I increment during the construction of the array
or I could use $#array+1 to get the number of elements.
I need the number of elements several times in my code, so if perl has to
iterate through the array every time I use $#array, it is better for
performance to use a separate variable which I increment while building the
array....
Cheers,
Helmut