in reply to Concise code to list array elements

Hi,

Your sigil is wrong to take an array slice. You'll need something like:

my @role = ( [ qw(a b c d e f g h i j k l m) ], [ qw(n o p q r s t u v w x y z) ], ); my $row = 0; say $role[$row][1], $role[$row][2], $role[$row][3], $role[$row][4], $r +ole[$row][5], $role[$row][6], $role[$row][7], $role[$row][8], $role[$ +row][9], $role[$row][10]; say @{$role[$row]}[1..10];

Also, make sure that you really want to skip the first element of the row in your example. Array indexes start at 0, not 1.

Replies are listed 'Best First'.
Re^2: Concise code to list array elements
by tel2 (Pilgrim) on Apr 08, 2013 at 04:18 UTC
    Thanks for that pointer, Loops.

    BTW, what does 'sigil' mean in this context?

      In a Perlish context, a sigil is the $, @, %, or & that precedes an identifier.

      Although it doesn't actually use the sigil word, perldata will help to understand the syntax of slices.


      Dave

        OK - thanks Dave.