jhuijsing has asked for the wisdom of the Perl Monks concerning the following question:

An occasional perl hacker need some advice

I have hash with a variable number of arrays stored in a hash and I want use use List::MoreUtils zip function on all the arrays to build a merged array

$hoa = ( obj1 = [ 1,2,3,5 ] obj2 = [ a,z,b,c,e] .. objx = [A1,Z2,Z5] }

What I want to do is this. How?

@order = zip ( obj1, obj2, .. objx )

Replies are listed 'Best First'.
Re: Passing a dynamic list of array names to a function
by ikegami (Patriarch) on Feb 25, 2015 at 22:49 UTC

    zip uses a prototype so you can do

    zip(@a1, @a2, @a3)

    What's actually passed to zip is a reference to each to those arrays. By overriding the prototype, you can pass those references yourself.

    &zip(\@a1, \@a2, \@a3)

    So next, we need to build a list of the reference. Why are you using a hash for ordered data?!

    &zip map $hoa->{"obj$_"}, 1..keys(%$hoa)