![]() |
|
Think about Loose Coupling | |
PerlMonks |
comment on |
( #3333=superdoc: print w/replies, xml ) | Need Help?? |
Several issues -- first, your slice isn't a slice. You need @sortarr[0..10]. Second, the content of each element is an array reference -- you need to slice out each part of that. p.272 is throwing you off because it's giving a slice of a row -- you're trying for a slice of a column (in a row-major AoA). You probably want to use map to extract the subslices. E.g.
For a column slice, for each element of the slice, @aoa[1,2] (i.e. the rows), this dereferences the array reference to get the column, and returns it as a new anonymous array reference. (This keeps it an AoA; if you want a flattened list, omit the square brackets just inside the map braces.). For two-dimensions, it's similar, but you slice inside the map, too. -xdg Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk. In reply to Re: Creating a Slice through a 2 dimensional array
by xdg
|
|