Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

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

Comment on Re: Counting elements in array
Select or Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1072623]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (12)
As of 2016-02-12 19:11 GMT
Find Nodes?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?

    Results (412 votes), past polls