Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: FIFO logfile done with flat file?

by tstock (Curate)
on Jul 28, 2002 at 20:48 UTC ( [id://185847]=note: print w/replies, xml ) Need Help??


in reply to FIFO logfile done with flat file?

my $filepath = "/tmp/fifo"; logInFIFO('log line example'); sub logInFIFO { my $logline = shift; my $fifolines = 5; my @log; if (-e $filepath) { open(IN, "< $filepath") || die $!; @log = (<IN>); close IN; } # transform and validate $logline here push @log, "$logline\n"; shift @log while ($#log > $fifolines-1); eval { open(OUT, ">$filepath") || die $!; print OUT @log; close(OUT) || die $!; }; return $@ ? warn($@) && 0 : 1; }
no file locking... buyer beware.

Tiago

Log In?
Username:
Password:

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

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

      No recent polls found