|
|
| Perl Monk, Perl Meditation | |
| PerlMonks |
Re^4: Range Operator in If Statementby Not_a_Number (Parson) |
| on Jan 06, 2012 at 11:15 UTC ( #946580=note: print w/ replies, xml ) | Need Help?? |
|
Could you explain... Let me try. First, [ 'A' .. 'F' ]is a reference to an anonymous arrray (see references quick reference). To access, for example, the second element of this array, the syntax is: [ 'A' .. 'F' ]->[1](You could also do ${ [ 'A' .. 'F' ] }[1] but I find the first form cleaner.) Then, instead of hard-coding the array index, my snippet calculates it in the fashion indicated in LanX's post above. The only difference is that I've removed int() since perl happily does this part of the job for me when I use a floating point number as an array index. To clarify, the following code, using a named array and an intermediate variable ($index), does the same thing:
hth, dave
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||