Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Understanding how to fork properly.

by particle (Vicar)
on Jan 31, 2002 at 02:39 UTC ( [id://142343]=note: print w/replies, xml ) Need Help??


in reply to Understanding how to fork properly.

you might want to try setting $| to some non-zero value. $| causes a buffer flush after every print statement (i think it works for write, too, consult the camel.)

most people write $|++;, but i prefer explicitly setting $|=1;. that way if some bonehead set it to -1 previously, the increment op wouldn't be doing the wrong thing.

oh, and this works by default on STDOUT. you'll have to specify autoflush on other filehandles by selecting them first, or by calling the autoflush method on the filehandle, something like $FH->autoflush();

~Particle

Replies are listed 'Best First'.
Re: Re: Understanding how to fork properly.
by dvergin (Monsignor) on Jan 31, 2002 at 04:07 UTC
    if some bonehead set it to -1 previously, the increment op wouldn't be doing the wrong thing.

    Oops! No. $| is magic. It always equals either zero or one. Nothing else. Behold:

    print "$|\n"; # 0 $| = -1; print "$|\n"; # 1 $|++; print "$|\n"; # 1 $|++; print "$|\n"; # 1 $|--; print "$|\n"; # 0 $|--; print "$|\n"; # 1 $|--; print "$|\n"; # 0
    As you can see, $|++ always sets $| to one (no matter what it was) and $|-- always toggles it.

    ------------------------------------------------------------
    "Perl is a mess and that's good because the
    problem space is also a mess.
    " - Larry Wall

(crazyinsomniac) Re^2: Understanding how to fork properly.
by crazyinsomniac (Prior) on Jan 31, 2002 at 04:34 UTC
      The Camel is a much more effective and satisfying LART than a hard drive, a monitor, or the full-sized server. Hey, if I've spent five minutes reeducating the guy, I don't want him to lose it with a concussion!
      it's a visceral thing for me. when i need to look something up quickly, i turn to books before i search online docs. every time. i like the feel of paper.

      i also prefer the index as search tool. maybe if there were good indexes online, not tables of contents and search tools, i'd look online more.

      i always travel with the camel. my copy is pretty beaten up, as it's seen thirty states in the past year alone. i suppose you could call it my perl security blanket :)

      ~Particle

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-04-25 14:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found