in reply to Re: Pushing Arrays into Hash without nesting
in thread Pushing Arrays into Hash without nesting

push (@{ $hash{foo}{bar} }, @{ addSomeNumbersFromSource("data") });

If addSomeNumbersFromSource() is not changed from the OPed code, then the
    return @array;
statement will be evaluated in scalar context (dereferencing a scalar array reference) and will return the number of elements in @array.

tybalt89 has it right for the given code:
   push (@ { $hash{"foo"}{"bar"} } , @{ (addSomeNumbersFromSource("data"))[0] } );

Update:

Just return the reference, and let the caller dereference and handle the list.
Hmmm... On reading 1nickt's reply and re-reading the post to which I was replying, I must admit that that post urged a significant change to the function interface, for which the suggested expression invoking the function was perfectly appropriate. Paying attention to what's written can sometimes be useful. :)


Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^3: Pushing Arrays into Hash without nesting
by 1nickt (Canon) on Feb 14, 2021 at 00:07 UTC

    Hm, yes, I did say "Just return the reference, and ...", in fact my whole point was that the subroutine should not return what the OP posted.


    The way forward always starts with a minimal test.