3 ms·
In Perl $#foo returns the index of the last element. To get the length you use @foo in scalar context. For eg: my @bag_of_stuff = qw(do re me fa so la si
by draegtun 16y ago
In Perl $#foo returns the index of the last element. To get the length you use @foo in scalar context. For eg:
my @bag_of_stuff = qw(do re me fa so la si);
say $#bag_of_stuff; # => 6
say scalar @bag_of_stuff; # => 7
NB. Lua arrays start at 1. Perl & most other languages start with 0 (zero) index
- _dan 16y agoYeah, I know (hence "kinda"), didn't seem like the time or place to go on about Perl's quirks, though ;)