(Bowing deeply, rhowerton humbly asks)
My understanding of autoflushing is that if you set $| = 1 then it is supposed to flush after a write (http://www.perlmonks.com/index.pl?node_id=20590), however it does not seem to be working. I am assuming that the print statement is a write and that it should print to the screen immediately upon execution. Here is the script I am trying to get working...understand it has changed many times as frustration has set in.
$|++; open(TCPDUMP,"/usr/sbin/tcpdump -i eth0:1 port 80 -s 60 -xX | grep GET + |") or die "Could not run command: $!"; my $DEBUG = 1; my $sleepTime = 5; my $count = 0; my $sleepCheck = 0; while(<TCPDUMP>) { chomp($_); print "$_\n"; FORK: { if($sleepCheck == 0) { if (my $pid = fork) { # parent here # child process pid is available in $p +id $count++; } elsif (defined $pid) { # $pid is zero here if defined # child here # parent process pid is available with + getppid $sleepCheck = 1; sleep($sleepTime); open(DUMPLOG, "> ./dump.log") or die " +Could not open dump log: $!"; print DUMPLOG "$count\n"; print "$count\n"; close(DUMPLOG); $sleepCheck = 0; $| = 0; exit(0); } elsif ($! == EAGAIN) { # EAGAIN is the supposedly recoverable + fork error if($DEBUG == 1) { print "Error: $!.\n"; } sleep 5; redo FORK; } else { # weird fork error die "Can't fork: $!\n"; } } else { $count++; } } }
Thank you in advance,
Ryan

In reply to Autoflushing revisited. by rhowerton

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.