in reply to How can I access the values of an "array" extracted using Range
The problem is that '$array' is not an array; it's an array reference - similar to a pointer. Your code seems fine, all except for that point. Quick overview of dealing with array references:
# Turning an arrayref into an array my @arr = @$aref; # Extracting a single value from an arrayref print ${$aref}[0]; # Or, more readable and less problematic: print $aref -> [0]; # Looping over the pointed-to list for my $i (@$aref){ ... }
In the above case, the structure that you're getting back from 'Range()' is an "AoA" - an array of arrays - which looks like this:
$aref = [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ];
Notice the second level of indirection, there? The result is that just converting the ref to an array is going to give you a list of... arrayrefs, which need to be expanded into arrays. The solution that netwallah shows is correct - I just wanted to give you a more general heads-up for this kind of problem. So, expanding the above looks like this:
for my $deref (@$aref){ for my $element (@$deref){ print "$element\n"; } }
Again, for more on data structures - AoAs, HoHs, etc. - see perldoc perlref and the excellent Data Structures Cookbook.
-- I hate storms, but calms undermine my spirits. -- Bernard Moitessier, "The Long Way"