On 10/10/07, Rob Dixon <[EMAIL PROTECTED]> wrote:
>
> Kaushal Shriyan wrote:
> > Hi,
> >
> > I am referring to http://www.gnulamp.com/perlscalars.html
> >
> > $a = $b; # Assign $b to $a
> >
> > Note that when Perl assigns a value with *$a = $b* it makes a copy of $b
> and
> > then assigns that to $a. Therefore the next time you change $b it will
> not
> > alter $a.
> >
> > I did not understand the Note:- Can some one make me understand this
> > statement with examples
>
> All they're saying is that $a = $b doesn't tie $a and $b together in any
> way,
> it just copies the value of $b to $a. If you change $b after that it won't
> alter $a again.
>
> > and also what i understand from the below statements( I have added in
> the
> > comments), is it correct.
> >
> > $a += $b;   #is it $a = $a + $b;
> > $a -= $b;    #is it $a = $a - $b;
> > $a .= $b;    #is it $a = $a . $b;
>
> Exactly right. Well done.
>
> Rob
>


Thanks Rob

All they're saying is that $a = $b doesn't tie $a and $b together in any
way, it just copies the value of $b to $a. If you change $b after that it
won't alter $a again.

Can you please explain me with a sample code. If I understand it correctly
does the below code  holds true for your explanation

#!/usr/bin/perl -w
$b = 2;
$a = $b;
print "$a\n";
$b = 4;
$c = $b;
print "$c\n";

Thanks again

Thanks and Regards

Kaushal

Reply via email to