different type of getting an array reference

From: Octavian Rasnita (orasnita_at_fcc.ro)
Date: 12/27/04


To: <beginners@perl.org>
Date: Mon, 27 Dec 2004 09:26:22 +0200

Hi all,

Can you please tell me what's the difference between these two types of
getting the reference to @a array?

my $ref = [ @a ];
and
my $ref = \@a;

If I do:
use Data::Dumper;
print Dumper $ref;

Both ways of accesing the @a array with a reference seems to be the same,
because Data::Dumper prints the same thing for $ref.

I need to access an array reference in a module, like...

my $self = [ @a ];
or...
my $self = \@a;

and I don't know if there will be any differences...

Thank you much.

Teddy



Relevant Pages

  • Re: How can I pass a multidimensional array as a ref parameter in func
    ... static int ReadFile(ref ushortnArray, ... > Array variable is the pointer to the address. ... > No 'ref' is needed. ... Ref is needed if your variable is not a reference ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: textbook authors: passing by ref is NOT more efficient!
    ... efficiency in terms of performance and we are talking reference objects. ... classic example (using int values, ... Console.WriteLine("Value after by ref routine ", ... reference to the array object even if you don't say "ref", ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: textbook authors: passing by ref is NOT more efficient!
    ... Ask them how long it takes to write a screen compared to the time difference in using 'ref' or not. ... reference to the array object even if you don't say "ref", ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: how to pass array and varaible
    ... ref even if you use a direct array. ... Make sure you pass var first, followed by array. ... > they no longer complicate argument passing. ... > a reference can take significantly less time. ...
    (perl.beginners)
  • Re: Pass by reference vs Pass by Value (is data aliasing a problem in C#?)
    ... You would pass a reference type with a ref keyword or out keyword when ... you need to modify what reference itself, not what the reference points to. ... // Passing an array to a method without the ref keyword. ...
    (microsoft.public.dotnet.languages.csharp)