in reply to subroutine - Passing Array Reference by Reference

This will pass a reference to a new copy of the original reference's data ("sub" is a really bad name for a sub, so I'll call it "stub"):

stub([@{$arrayRef}]);
That only copies down one level, so if $arrayRef is an AoA or something you'll need to adapt a deeper copy for true isolation;
stub([map {[@$_]} @$arrayRef]);
for an AoA, or
stub([map {{%$_}} @$arrayRef]);
for an AoH, for instance.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re^2: subroutine - Passing Array Reference by Reference
by awohld (Hermit) on Oct 30, 2005 at 04:24 UTC
    Can you guys reccomend any good books that go indepth on references?
      "Learning Perl Objects, References & Modules", O'Reilly Publ.
      chas