in reply to Converting an Array Reference into an Array
Under the hood, an array reference and an array are the same thing. (There are just two hoods to look under with an array reference.) Your technique for turning an array reference into an array is workable and the proper way to do it, but you are paying the penalty of cloning the array because you're copying things.
There's really no good way to do what you're suggesting without cloning things, unless you want to be very sneaky and mess with typeglobs. I prefer this dereferencing syntax, though:
my $element = $PassedArrayRef->[ $index ];Just for kicks, here's the typeglob/global syntax you really oughtn't use. (If you don't understand it, you're probably better off!)
local *notacopy; *notacopy = $PassedArrayRef; my $element = $notacopy[ $index ];
I can't think of a good reason to do that, though.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Converting an Array Reference into an Array
by NetWallah (Canon) on Mar 12, 2003 at 17:54 UTC |