Acme-Hyperindex
view release on metacpan or search on metacpan
lib/Acme/Hyperindex.pm view on Meta::CPAN
my $particle = $struct[0]{w_plus_wino}[2];
But what if you don't know how deep your datastructure is
at compile time? 'Course this is doable:
my $particle = \@struct;
$particle = $particle->[$_] for qw(0 pion 2);
Two problems here: Perl will tell you 'Not an ARRAY reference'
once we try to index in the hash on 'pion' with this array indexing syntax.
It's damn ugly and looks complicated.
So Acme::Hyperindex lets you index arbitrary deep into data structures:
my $particle = @struct[[ 0, 'pion', 2 ]];
-- or even --
my $particle = @struct[[ @indexes ]];
-- or --
my $particle = @struct[[ get_index() ]];
-- or --
my $particle = @struct[[ $particleindexes[[ 3, 42 ]] ]];
( run in 4.065 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )