Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Reopen file when contents changed?

by blazar (Canon)
on Jun 07, 2005 at 13:39 UTC ( #464298=note: print w/replies, xml ) Need Help??


in reply to Reopen file when contents changed?

You may simply want seek. I'm not really sure if it is well suited for that particular file, which may not be the case. It' worth trying in any case.

Incidentally under *NIX there's not strictly speaking anything like "text mode".

Update: I didn't want to test this myself, but in the end I did and it seems to work just fine:

#!/usr/bin/perl use strict; use warnings; open my $fh, '<', '/proc/stat' or die $!; { print scalar <$fh>; seek $fh, 0, 0; sleep 1; redo; } __END__

Replies are listed 'Best First'.
Re^2: Reopen file when contents changed?
by dReKurCe (Scribe) on Jun 07, 2005 at 21:15 UTC
    That code worked for me and generated output has follows:
    cpu 757611 0 128970 6183389 cpu 757611 0 128970 6183507 cpu 757611 0 128970 6183608 cpu 757612 0 128970 6183708 cpu 757612 0 128970 6183809

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2022-08-18 05:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?