note
Not_a_Number
<blockquote>Could you explain...</blockquote>
<p>Let me try. First,</p>
<c>[ 'A' .. 'F' ]</c>
<p>is a reference to an anonymous arrray (see [references quick reference]). To access, for example, the second element of this array, the syntax is:</p>
<c>[ 'A' .. 'F' ]->[1]</c>
<p>(You could also do <c>${ [ 'A' .. 'F' ] }[1]</c> but I find the first form cleaner.)</p>
<p>Then, instead of hard-coding the array index, my snippet calculates it in the fashion indicated in [LanX]'s post [id://946313|above]. The only difference is that I've removed <c>int()</c> since perl happily does this part of the job for me when I use a floating point number as an array index.</p>
<p>To clarify, the following code, using a named array and an intermediate variable (<c>$index</c>), does the same thing:</p>
<c>my @array = ( 'A' .. 'F' );
my $ref_number = 42; # or whatever
my $index = ( $ref_number - 1 ) / 8;
my $bundle = $array[ $index ];
print $bundle;
</c>
<p>hth, dave</p>
946284
946461