[Chicago-talk] Array slices

tiger peng tigerpeng2001 at yahoo.com
Sun Nov 5 18:11:56 PST 2006

Isn't slice implemented as iteration in Perl5?
Perl6 may have what you wanted.

May be you can flattened the array and slice it, if your array of array (of array ...) is in a rectangle(, or cube...)

----- Original Message ----
From: Jay Strauss <me at heyjay.com>
To: Chicago.pm chatter <chicago-talk at pm.org>
Sent: Sunday, November 5, 2006 6:47:29 AM
Subject: [Chicago-talk] Array slices


Is there any way other than iteration to get an array slice of a
multi-dimensional array?

For example, I'd like to create a slice out of the 2nd element of each
inner array, so that my result would be (2,4,6).

@a = ([1,2],[3,4],[5,6]);

print join @a[][1],"\n";  # doesn't work
print join @a[0..2][1],"\n"; #doesn't work

Obviously I can use any type of loop structure to build the desired
array, I just thought there would be shorthand syntax.

Chicago-talk mailing list
Chicago-talk at pm.org

More information about the Chicago-talk mailing list