Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Counting elements in array

by vinoth.ree (Monsignor)
on Jan 30, 2014 at 05:05 UTC ( #1072623=note: print w/replies, xml ) Need Help??


in reply to Counting elements in array

I prefer the following

my @Array = (1,2,3,4); say 0+@Array; #@Array as a number)

Its clearer than

say scalar(@Array);  #@Array as a scalar)

If you just want to print the size, this is the simplest way.

print "size of array: " . @array . ".\n";

All is well

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1072623]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2017-11-20 08:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (286 votes). Check out past polls.

    Notices?