if you talking about operators precedence, so we can calculate that expression by the next way:
$x + ++$x + $x++:
first:
++$x - ok, at now here returns 6.
second:
$x++ - ok, at now here return 6, but $x will right now is 7
so we must get 21, if anywhere we get $x object as is, -but it isn't so.
we can get 19, if we get values, not objects - i've mean
7+6+6
we will get
5(value of copy of the object before any object changes)+7(at this position is value of original object $x)+6(at this position copy of $x after we make ++$x) == 18 - by logic which I describe.
Let's make first other operation - $x++ not ++$x -
we get 5 here anyway.
then we make ++$x ($x == 6 ) - ok - we get 7 here.
7+5==12.
for getting at now 18 as a result we must take $x==6 - look's like it is absolutely wrong.
so..
by operators precedence from perlop(at perldoc) we can say that we calculate it from left to right.
why in position of $x - we get value of copy $x not for the moment of calculation, but for the moment of expression calculation begin.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.