Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: Perl Idioms Explained - $|++

by NetWallah (Canon)
on Aug 01, 2003 at 23:17 UTC ( [id://280188]=note: print w/replies, xml ) Need Help??

in reply to Perl Idioms Explained - $|++

Re: sauoq's comment:First, we don't need Yet-Another-Pair-Of-Constants-For-Zero-And-One.

I agree that it is ugly to have to declare those constants - If I had my way, they would be easily import-able, probably with use English;; but I do think it makes the code more readable/maintainable.

The objective is to allow moderately knowledgible perl-ites to be able to read the code, and be fairly confident that they understand it, without having to refer to a manual.

In this case, even using the name "$OUTPUT_AUTOFLUSH=1" does not clue the reader that his output is now UNBUFFERED. Hence, even with use English; (which is a good idea), I would still use the constants.

Replies are listed 'Best First'.
Re: Re: Perl Idioms Explained - $|++
by ctilmes (Vicar) on Aug 01, 2003 at 23:23 UTC
    If they don't know that "AUTOFLUSH" flushes the output automatically, they probably don't know what the heck "UNBUFFERED" means.

    (And the converse -- if they have any clue what flushing is at all, they probably know what "AUTOFLUSH" means.)

      Can you tell me if I need to specify the $|++ (or equivalent) in "ALL" perl scripts within a process; or only the main driver. I have about 50 perl scripts several layers deep (i.e. "A" invokes "B" which invokes "C" and "D" and "E" etc.....) By the way I have tried it in a few scripts with no luck yet ... the output to my screen still only displays every 50 lines or so. Are they any gotcha's? Thanks Wayne

        $| works per process. So if you use one script that sources other scripts (e.g. using do $filename, require, eval $string), once is sufficient. If you start scripts from other scripts using system, exec, qx a.k.a. ``, pipe open (| somewhere in the open arguments), each script runs in its own process and thus has its own $|.


        Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://280188]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-06-17 03:10 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.