but not sure if that really works...Then just test it for yourself:
use strict; use warnings; my @a0; my @a1 = 1; my @a2 = 0..5; check(@a0); check(@a1); check(@a2); sub check { if (@_ == 1) { #if ((scalar @_) == 1) { print "exactly 1\n"; } else { print "diff from 1\n"; } } __END__ diff from 1 exactly 1 diff from 1
Your original method seems to work pretty well.
You could make it more verbose by using scalar. You decide which is simpler for you to understand.
In reply to Re: Test Number of Elements In Array
by toolic
in thread Test Number of Elements In Array
by walkingthecow
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |