Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: Array length with range operator

by Happy-the-monk (Abbot)
on Jun 06, 2013 at 06:39 UTC ( #1037377=note: print w/ replies, xml ) Need Help??

in reply to Array length with range operator

or try this ;-)

perl -wE'say scalar @{["aa".."zz"]}'

Cheers, Sören

(hooked on the Perl Programming language)

Comment on Re: Array length with range operator
Download Code
Replies are listed 'Best First'.
Re^2: Array length with range operator
by gurpreetsingh13 (Scribe) on Jun 06, 2013 at 07:25 UTC

    Good trick.

    Anonymous array - then convert the ref. back to array and apply scalar to it.

      Also works for "highest index" rather than "number of elements":

      >perl -wMstrict -lE "say scalar $#{[ 'aa' .. 'zz' ]}; " 675

        Or insert commata and count them ;-)

        perl -wE "say 1 + join(',','aa' .. 'zz') =~ tr/,//;"

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2016-02-14 06:03 GMT
Find Nodes?
    Voting Booth?

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

    Results (457 votes), past polls