in reply to how to assign map results to arrays

i like reference approach and it works, but i have to dereference it though, thanks for the tip

 ($ar1, $ar2) = map { [split(';', $_)] } ($num1, $num2);

not quite understand why dose Perl flatten the results.

Replies are listed 'Best First'.
Re^2: how to assign map results to arrays
by davorg (Chancellor) on Jul 29, 2008 at 11:10 UTC
Re^2: how to assign map results to arrays
by ikegami (Patriarch) on Jul 29, 2008 at 19:28 UTC

    not quite understand why dose Perl flatten the results.

    Because Perl functions can only return one thing: a list of scalars. A list of scalars is created from the two arrays and returned by map.

    Then you ask to assign that list to a pair of arrays. There's no way for Perl to know how to split that list to assign it to two arrays, so it assigns the entire list to the first array.