I have an array @ary
of unknown size. Each element, $ary[$i]
, is an arrayref of unknown size. Each element of that, $ary[$i][$j]
, is a string.
I wish to concatenate all of the $ary[0][$j]
with all of the $ary[1][$j]
with all of the… and so on.
That is, suppose my array looks like this:
$ary[0] = ['foo', 'fun'];
$ary[1] = ['bar', 'bun', 'blip'];
$ary[2] = ['baz', 'zun'];
Then I'd want the return
to be:
(
'foo bar baz',
'foo bar zun',
'foo bun baz',
'foo bun zun',
'foo blip baz',
'foo blip zun',
'fun bar baz',
'fun bar zun',
'fun bun baz',
'fun bun zun',
'fun blip baz',
'fun blip zun'
)
(Alternatively, the return
could be an array of arrayrefs: (['foo', 'bar', 'baz'], ['foo', 'bar', 'zun'], …)
.)
How can I do this?