in reply to Using exists to check element in array
We had recently a discussion covering this, see Re^3: extracting a list element ( 'delete @array' explained) and connected thread.
> In my situation the numerical keys ($elementIndex) are not contiguous
Personally I think if you really know what you are doing, you should just silence this warning.
NB: But sparse arrays with gaps of non-existing elements are normally more efficiently implemented with hashes.²
Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery
¹) and because Data::Dumper is kind of lying about non-existing elements.
²) and hashes have the advantage that the number of existing keys is readily available. The length of an array with gaps OTOH is of no help, especially because after a delete all non-existing entries will be truncated from the end.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Using exists to check element in array
by david (Novice) on Jan 28, 2024 at 10:09 UTC | |
by LanX (Saint) on Jan 28, 2024 at 10:18 UTC | |
by david (Novice) on Jan 28, 2024 at 10:51 UTC |