Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: creating 2D arrays

by PrakashK (Pilgrim)
on Jul 24, 2001 at 21:18 UTC ( #99416=note: print w/replies, xml ) Need Help??

in reply to creating 2D arrays

As has already been explained by others, a reference must be used in place of an array itself.

I'd like to add just one thing. For performance reasons, i'd rather change the sub mult to return the array reference rather than the array itself. Also, pass an array reference as the second param to mult instead of an array.

sub mult { my ($a, $b) = @_; # dereference the array, process it and create a new array .... return \@c; } ## Assuming that the array @b is a 2D array too for $i (0..$N){ push @results, mult($a, $b[$i]); }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://99416]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2018-06-22 23:27 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (124 votes). Check out past polls.