in reply to creating 2D arrays

You should take a look at perllol which contains everything you need to know about multdimensional arrays.

Your last code should be changed to:

for $i (0..$N){ $results[$i] = [ mult($a,@b[$i]) ]; }

The [] is called an array reference constructor. Without this constructor your array is called in scalar context and it'll just return the number of elements it contains.

Update Fixed my code, thanks to PrakashK, and remove the push.

- Good luck

Replies are listed 'Best First'.
Re: Re: creating 2D arrays
by PrakashK (Pilgrim) on Jul 24, 2001 at 21:09 UTC
    Without this constructor your array is called in scalar context and it'll just return the number of elements it contains.
    Small correction.

    push does not evaluate its second argument in scalar context, rather it expects a list. Even if a scalar is pushed, it would be as if the second parameter is a one-element list.