sub indices ($@) { # note the prototype has target, then list my $target = shift; my (@list) = @_; my $index = 0; map { $_->[1] } grep { $_->[0] eq $target } map { [$_ , $index++] } @list; }