#!perl use strict; use warnings; foreach my $val ( qw/ one one three two one / ) { print scalar { map { @{[(qw/one two three/, reverse (1..3))]}[$_ - 1, -$_] } (1..(2 * @{[1..3]})) }->{$val}, "\n"; }