http://www.perlmonks.org?node_id=1037377


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)

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

    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/,//;"