Try using a second variable to trace the values as it goes:

$a = 0
$b = 1
$a = $b++
print "$a=", $a, " $b=", $b

$a = 0
$b = 1
$a = ++$b
print "$a=", $a, " $b=", $b


From the Perl 5 Programmer's Notebook, Jesse Feiler, Prentice Hall, 2000:

When the autoincrement operator (++) is placed after the variable, it
is used (assigned) then incremented
When the autoincrement operator (++) is placed before the variable,
the increment is done before the variable is used

Hope that lessens the confusion

>>     Michael> $b = 1; $b = $b++;
>>     Michael> Result:
>>     Michael> $b = 1
>>
>>$b++ is synonymous with $b = $b + 1.  So, your second statement reads:
>>
>>'$b = $b = $b + 1'.
>>
>>If you replace your code with:
>>
>>'$b = 1; $b++;' or '$b = 1; $b = $b + 1', you'll get more expected
>>behaviour.  :)
>>
>>- Chris.
>>--
>>
>
>
>Thanks for the response, Chris,
>
>but check this out:
>
>$b=1;
>$b = ++$b;
>result: 2
>
>So, that isn't the whole story. This has to do with pre- & post
>"timing", I think.
>
>/Michael Turner
>
>
>--
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]


--
Dave Tenen
basicSolutions
59 Spec Pond Ave.
Lancaster, MA. 01523

Phone:(978) 537-6234
FAX:    (978) 537-2496
Cell:   (508) 873-8301
e-mail:[EMAIL PROTECTED]

      "Let your solutions be our problems!"

Coming to you from Spec Pond, and I swear that fish
was [_______________________________________] that big!!!

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

Reply via email to