On 10/10/07, Jenda Krynicky <[EMAIL PROTECTED]> wrote: > > From: yitzle <[EMAIL PROTECTED]> > > On 10/10/07, Kaushal Shriyan <[EMAIL PROTECTED]> wrote: > > > > > > Can you please explain me with a sample code. If I understand it > correctly > > > does the below code holds true for your explanation > > > > Lets put it this way. > > I the world of C/C++, there's something called a pointer. > > In the world of Perl, there's something called a reference. > > > The syntax of Perl and C/C++ is not the same, but I'll make an > effort.... > > You can have code like this: > > > > *c = 5; // The thing that $c points to now is 5 > > $$c = 5; > > > a = c; // Now a and c are the same, ie refer to the same item. printing > "$a > > = $c" would print "5 = 5" > > $a = $c; # now, just like in C, $a and $c have the same value, > # ie refer to the same item > # printing "$$a = $$c" would print "5 = 5" > # and just like you have to dereference the variables in > # Perl, you'd have to dereference them in C: > # printf( '%s = %s', *a, *c); > > > *c = 6; // The thing that $c points to now is 6. $a points to the same > thing > > as $c does, so now print "$a" would print 6. Even though $a wasn't > changed!! > > $$c = 6; # and print "$$a" would print 6. > > > > Anyhow, the point is that Perl doesn't have those confusing weird > "pointer" > > stuff. $a and $c do not "point" to the same place, the just got the same > > value. (Well, Perl /does/ have pointers, but... whatever.) > > Yeah, it does seem you are pretty confused by pointers in C. And > probably by references in Perl too. I wonder how can you program > without understanding pointers/references, but whatever. > > Jenda
The purpose of my message was to clarify the part of the documentation that Kaushal asked about. I am aware that Perl has pointers/references, as I mentioned, but the question is not /about/ pointers, but variables. The documentation seems to be contrasting variables to pointers. Rather than introducing perl references, I thought I could use a bit of C to explain how it is possible that by changing $b, you affect $a, and then say with normal Perl variables (I know, the word "normal" is wrong) do not exhibit this behavior. I was trying to avoid being overly technical and trying to explain the concept in a way that someone unfamiliar with pointers or references would be able to understand them. How did my code indicate to you that I am confused about C pointers? It looks pretty correct to me... And Perl references? I mention they exist, but tried avoiding talking about them in this explanation. I use references and pointers in programming, but in this explanation, I believe I dealt with them correctly.