in reply to How do I access only certain elements of a multidimensional array?
See perldsc. (Update: And also Slices in perldata.)c:\@Work\Perl\monks>perl -wMstrict -le "my @shapes = ( [qw/circle square triangle polygon/], [qw/red green blue yellow fuschia/], [qw/a b c d e f g h i j k/] , [qw/Movie TV Radio/] , ); ;; for my $arrayref (@shapes) { printf qq{'$_' } for @{$arrayref}[ 2 .. $#$arrayref ]; print ''; } " 'triangle' 'polygon' 'blue' 'yellow' 'fuschia' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'Radio'
Update: Or if you don't want to use a slice, maybe
c:\@Work\Perl\monks>perl -wMstrict -le "my @shapes = ( [qw/circle square triangle polygon/], [qw/red green blue yellow fuschia/], [qw/a b c d e f g h i j k/] , [qw/Movie TV Radio/] , ); ;; for my $arrayref (@shapes) { printf qq{'$arrayref->[$_]' } for 2 .. $#$arrayref; print ''; } " 'triangle' 'polygon' 'blue' 'yellow' 'fuschia' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'Radio'
Give a man a fish: <%-{-{-{-<
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How do I access only certain elements of a multidimensional array?
by Ppeoc (Beadle) on Nov 01, 2015 at 02:36 UTC | |
|
Re^2: How do I access only certain elements of a multidimensional array?
by Ppeoc (Beadle) on Nov 01, 2015 at 03:26 UTC | |
by Cristoforo (Curate) on Nov 01, 2015 at 04:55 UTC | |
by AnomalousMonk (Archbishop) on Nov 01, 2015 at 12:42 UTC |