I fail to see the problem. Pre-increment means that the value
will be incremented before the value is returned. Post-increment means the value will be incremented after it
is returned. It's very important to realize that it is
not defined exactly when the increment occurs. It will be done after execution of the
current statement started, and will be done before the
statement is finished, but that's all you get.
So, for your first line, you could get "2:2", or "2:1" and
for the second line, you could get "1:2" or "1:1". Or some
other weird value for the second $a.
As a rule, never use a variable you are pre- or post incrementing or decrementing a second time in the same
statement. And most certainly, don't modify the variable
a second time. The following is undefined:
my $i = 0;
$i = ++ $i;
meaning that if perl decides to erase your hard disk,
it's still well inside the boundaries of its specification.
Abigail
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.