Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^5: Array length with range operator

by AnomalousMonk (Monsignor)
on Jun 06, 2013 at 19:04 UTC ( #1037502=note: print w/ replies, xml ) Need Help??


in reply to Re^4: Array length with range operator
in thread Array length with range operator

But that's back to giving you the number of elements or, in general, something based on that number. De-referencing from  $#{[ LIST ]} gives you the highest index even if someone's been messing with  $[   (but Don't Do That!).

Although why anyone would want to know the highest index of an array that no longer exists at the moment the datum is produced is beyond me — but then, the whole do-it-in-one-statement fixation escapes me, so...

>perl -wMstrict -lE "say 1 + join(',','aa' .. 'zz') =~ tr/,//; ;; $[ = 2; say $#{[ 'aa' .. 'zz' ]}; " Use of assignment to $[ is deprecated at -e line 1. 676 677


Comment on Re^5: Array length with range operator
Select or Download Code
Re^6: Array length with range operator
by hdb (Parson) on Jun 07, 2013 at 07:53 UTC

    Probably the original question was: "How many combinations of two letters are there?" and then someone thought: "We should be using Perl to answer the question."

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2014-07-26 07:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (175 votes), past polls