Think about Loose Coupling | |
PerlMonks |
Re: Puzzling $| behaviorby mwah (Hermit) |
on Oct 07, 2007 at 21:56 UTC ( [id://643331]=note: print w/replies, xml ) | Need Help?? |
Yesterday I wrote the following "opinion": | print gets its "arguments in reverse order", similar to C. | The above call would (in C) look like |(pseudocode): | ... | XPUSH( "\n" ); | XPUSH( $| ); | $|--; # plus true/false magic | XPUSH( "second=" ); | XPUSH( $| ); | XPUSH( "first=" ); | PUTBACK; | 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: the important output will be: from where it can be learned that the $| decrement occurs (postdec [4]) where it should. Sorry for writing such a mess without checking before :-( Regards mwa /1/ perl -MO=Bblock mysource.pl
In Section
Seekers of Perl Wisdom
|
|