Yesterday I wrote the following "opinion":
| print gets its "arguments in reverse order", similar to C.
| The above call would (in C) look like
| XPUSH( "\n" );
| XPUSH( $| );
| $|--; # plus true/false magic
| XPUSH( "second=" );
| XPUSH( $| );
| XPUSH( "first=" );
| call_pv("print", G_ARRAY);
| (please correct here me if I'm wrong)
which turned out to be completely wrong.
After reading the other posts and looking further
into the topic, I came to the conclusion that perl
evaluates the argument list before calling into a sub-
routine always left-to-right.
This can be shown by reading the deparsed output
from B::Bblock /1/. If used on the following lines:
1: $| = 1;
2: print "first=", $|, " second=", $|--, "\n";
the important output will be:
OP (0x824de58) enter
COP (0x81f3290) nextstate
#1 $| = 1
SVOP (0x824dc80) const  IV (0x8167cdc) 1
PADOP (0x818ae48) gvsv GV (0x8168894) *|
BINOP (0x8189398) sassign
COP (0x824c638) nextstate
OP (0x8250178) pushmark
SVOP (0x8189428) const  PV (0x816881c) "first="
PADOP (0x818c6f0) gvsv GV (0x8168894) *|
SVOP (0x818de00) const  PV (0x8168828) " second="
PADOP (0x824ff88) gvsv GV (0x8168894) *|
UNOP (0x824fe50) postdec 
SVOP (0x824de38) const  PV (0x81688b8) "\n"
LISTOP (0x8250150) print
LISTOP (0x824dac0) leave 
from where it can be learned that the $| decrement
occurs (postdec 
) where it should.
Sorry for writing such a mess without checking before :-(
/1/ perl -MO=Bblock mysource.pl
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
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:
Outside of code tags, you may need to use entities for some characters:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] |