[oak perl] newbie array question
Sandy Santra
santranyc at yahoo.com
Wed Jan 5 00:00:00 CST 2005
Hi, I'm a very new newbie learning arrays. Apologies for
the length of this--it's all just a little hard to grasp
at this point.
I have a perlintro document that says don't bother using
$#array + 1
for determining the number of items in an array, implying
there's a shortcut. But it doesn't really give me a simple(r)
way of doing it.
I just want the print command to produce the number of items,
but none of the following work:
print @arrayname;
print '@arrayname';
print "@arrayname";
I was hoping at least the first of those would, since I
thought something without quotes usually implied same was
a number, and Perl is supposed to give me a number when
it sees @arrayname in a scalar context, right?
Is this the only way to do it...
print scalar @arrayname;
???
Seems longer than
print $#array + 1;
(if that even works)
So I'm a little confused, partly because I'm reading a chapter
on arrays and the print command is used in almost none of
the coding examples.
Any help appreciated. Thanks.
--Sandy Santra
More information about the Oakland
mailing list