in reply to Re: a HASH ref while "strict refs" ERROR
in thread a HASH ref while "strict refs" ERROR

Considering that the first thing each sub does is copy all the elements of the array, there's not much point in passing a ref and dereferencing it. Just sling the arrays around.
sub higherLevel { my(@arr) = @_; showArray(@arr); } sub showArray { my(@arr) = @_; foreach my $temp (@arr) { print "$temp\n"; } } my(@arr) = ("one","two","three"); higherLevel(@arr);

Caution: Contents may have been coded under pressure.

Replies are listed 'Best First'.
Re^3: a HASH ref while "strict refs" ERROR
by ikegami (Patriarch) on May 04, 2005 at 19:27 UTC

    You're right

    sub test_arr { my @arr = @_; $a = join('|', @arr); } sub test_ref { my @arr = @{$_[0]}; $a = join('|', @arr); } sub test_ref2 { $a = join('|', @_); }
    TINY ARRAY Rate ref arr ref2 ref 120870/s -- -14% -17% arr 140004/s 16% -- -4% ref2 145146/s 20% 4% -- SMALL ARRAY Rate ref arr ref2 ref 61587/s -- -8% -58% arr 67214/s 9% -- -54% ref2 146895/s 139% 119% -- GIANT ARRAY Rate ref arr ref2 ref 850/s -- -0% -99% arr 850/s 0% -- -99% ref2 148539/s 17383% 17381% --

    The arrays would have to be pretty damn big for it to matter if one does my @arr = @_.