in reply to Defining an anonymous hash with slices and lists.
or just typed in once, but with one additional variable used within the outer map#!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"; }
I could of course (ab)use an internal variable, but it remains another variable. Anyone have an idea?#!perl use strict; use warnings; foreach my $val ( qw/ one one three two one / ) { print scalar { map { my $intern = $_; map { @{$intern}[$_ - 1, -$_] } (1..@{$_}) } ([(qw/one two three/, reverse (1..3))]) }->{$val}, "\n"; }
|
|---|