sub size_index { my $val2 = $#array + 1; }
Just... don't... do... that!! Express what you *mean* or use some obfuscational language like C, (non-parrot) assembler or Java. If you want to express "if not" then type "if not". If you mean "unless", then use "unless". If you mean array size then DON'T say "index of the last element plus one".
Is scalar(@array) is slower because it requires a function call?
Yes. But don't let its being slower stop you from using it. 1.8 million per second or 3.2 million per second -- if that matters, Perl is not the right tool for the job.
Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }In reply to Re: Timing of Array-Size Determination Methods
by Juerd
in thread Timing of Array-Size Determination Methods
by Itatsumaki
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |