> ( grep { !exists( $a[$_] ) } keys @a ) ? "can" : "didn\x27t" );
Looks like keys @array was added to Perl in 5.12
And it's obviously inconsistent to delete and exists .
> The very existence of this inconsistency is reason enough for a warning.
But it's even worse!!!
keys is inconsistent to the behavior in hashes, even without using delete and exists and ever seeing any warnings !!!
my (@y,%y); $y[3]=$y{3}=1; say "keys \%y: ", join ",",keys %y; say "keys \@y: ", join ",",keys @y;
-->
keys %y: 3 keys @y: 0,1,2,3
A consistent implementation of keys ARRAY should check with exists first before returning an index.
Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery
In reply to Re^6: Using exists to check element in array
by LanX
in thread Using exists to check element in array
by david
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |