For Programmers: Free Programming Magazines  


Home > Archive > PERL Programming > November 2006 > reading from updated file









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author reading from updated file
Devon Banks

2006-11-27, 6:57 pm

I have been wondering if there is a simple way to read from a file
that is constantly being updated. How do you do this without reading
duplicates?
I guess the most pervasive example would be a log file.
I've seen where some perl scripts can do this such as swatch but
have never figured out what they were doing. Is there a recommended
standard way of doing this?
Do you have to read the whole file each time you scan for updates?
Paul Lalli

2006-11-27, 6:57 pm

Devon Banks wrote:
> I have been wondering if there is a simple way to read from a file
> that is constantly being updated. How do you do this without reading
> duplicates?
> I guess the most pervasive example would be a log file.
> I've seen where some perl scripts can do this such as swatch but
> have never figured out what they were doing. Is there a recommended
> standard way of doing this?
> Do you have to read the whole file each time you scan for updates?


I would recommend the CPAN module File::Tail, which is designed
specifically for this task. Read about it and download it at:
http://search.cpan.org/~mgrabnar/Fi...-0.99.3/Tail.pm

Paul Lalli

Mumia W. (reading news)

2006-11-27, 6:57 pm

On 11/27/2006 08:58 AM, Devon Banks wrote:
> I have been wondering if there is a simple way to read from a file
> that is constantly being updated. How do you do this without reading
> duplicates?
> I guess the most pervasive example would be a log file.
> I've seen where some perl scripts can do this such as swatch but
> have never figured out what they were doing. Is there a recommended
> standard way of doing this?
> Do you have to read the whole file each time you scan for updates?


I assume that you have ActiveState Perl for Windows and its
documentation installed, so do this:

Start->Run->"perldoc -q tail"

For more information about perl, do this:

Start->Run->"perldoc perl"

If you are using Linux, open an X-terminal and type this:

perldoc -q tail

.... and this ...

perldoc perl


Good luck


--
paduille.4060.mumia.w@earthlink.net
Paul Lalli

2006-11-27, 6:57 pm

Mumia W. (reading news) wrote:
> On 11/27/2006 08:58 AM, Devon Banks wrote:
>
> I assume that you have ActiveState Perl for Windows


I wonder what made Mumia assume that, as nothing in the OP's post
suggested or implied it.

> and its documentation installed, so do this:
>
> Start->Run->"perldoc -q tail"
>
> For more information about perl, do this:
>
> Start->Run->"perldoc perl"


.... unless, of course, you'd like to be able to actually *see* the
results of that command, rather than just the flash of a black box on
your screen. In that case, do:
Start->Run>"cmd"
and then type one of the commands Mumia put in double quotes above.

Paul Lalli

Devon Banks

2006-11-27, 9:57 pm

On Mon, 27 Nov 2006 07:07:18 -0800, Paul Lalli wrote:

> Devon Banks wrote:
>
> I would recommend the CPAN module File::Tail, which is designed
> specifically for this task. Read about it and download it at:
> http://search.cpan.org/~mgrabnar/Fi...-0.99.3/Tail.pm
>
> Paul Lalli


Thanks for your replies, I haven't used ActiveState perl for a
while. I've always been concerned about writing a perl script
and finding a system doesn't have it installed. Of course for
windows I would use it.
Thanks again.

Paul Lalli

2006-11-28, 7:58 am

On Nov 27, 9:15 pm, Devon Banks <devon_ba...@comcast.net> wrote:
> On Mon, 27 Nov 2006 07:07:18 -0800, Paul Lalli wrote:
>
>Thanks for your replies, I haven't used ActiveState perl for a
> while. I've always been concerned about writing a perl script
> and finding a system doesn't have it installed. Of course for
> windows I would use it.


My response has nothing to do with ActiveState - that was all Mumia.
My recommendation of using File::Tail is valid for any operating
system.

Paul Lalli

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com