in reply to Puzzling $| behavior
$| = 0; print "first=$|,"; $|--; print "second=$|\n"; $| = 1; print "first=$|,"; $|--; print "second=$|\n";
In your first case, Perl evaluates the second $|, then decrements it, then evaluates the first one, leading to the unexpected behavior. The reason you don't end up with "-1" is that there is magic associated with $|. It doesn't actually hold a value, it just tracks whether it is set to a non-zero value or not. Try for instance $| = -3; print $| to see this behavior.
Read perlvar and perlop for more information on what is going on here.
|
|---|