Yes and no.  I think that if you understand the concept of pointers, then
you will be able to understand references more easily, but from what keep
hearing from c/c++ people, there are differences.  Perhaps someone else on
the list can clarify more.

One thing that Perl can do with references that I don't _think_ you can do
in C is the concept of anonymous data structures.  Take this as an example.

        my @arrayOfHashes = ();
        push(@arrayOfHashes, {first => 'foo', second => 'bar', third =>
'nuts'});

I've now added an element to @arrayOfHashes which is a pointer to an
anonymous hash containing three keys.  I can then access the hash like this:

        foreach(@arrayOfHashes){
          print "The first is $->{first}\n";
          print "The second is ${$_}{second}\n";
      }

The first example accesses the key indirectly, and the second one
dereferences the $_ variable first.  In the second example, we could refer
to the hash as %{$_}.

-----Original Message-----
From: christopher j bottaro [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 06, 2002 11:58 AM
To: [EMAIL PROTECTED]
Subject: references in perl...


hello,
i'm a c/c++ programmer trying to learn perl.  there are just some things
that 
are much more easily done in a language like perl than in c/c++ i've found 
out...=)  anyways, i'm reading a short tutorial about references.  am i
wrong 
in thinking they are like pointers in c/c++?

-- christopher

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to