From: "Bee" <[EMAIL PROTECTED]>
> Say I have an array that carries at least 2mb data or 70mb max,
> but in my code, I want to throw this array to another sub ( within the
> same package )for further  operations . so, which one I would better
> to use and what's the reason ?
> 
> gosub [EMAIL PROTECTED]
> or
> gosub @array 

Definitely the first.
 
> Is that if I  throw the array to another sub also means the 
> array would be copied and then pass to the target sub ?
> while reference is using the same data in system memory?

The first version passes just the reference to the already existing 
array while the second creates a new array containing aliases to the 
items in the original array. This means that unless you do

        sub foo {
                my @array = @_;
                ...

you do not have copies of the elements in the array, but you do force 
Perl to create an array. I'm not sure how many bytes do the aliases 
take, but if the array has many elements you probably do not want to 
do that.

The
        my @array = @_;
in the sub would create a copy of the array and the values.

Jenda
P.S.: You do not throw values to subs, you pass them. You only throw 
exceptions.
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to