Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

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]
[atcroft]: .oO(Plus it was a little slow for a few minutes, at least... ;) )

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2018-02-24 20:47 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (311 votes). Check out past polls.