in reply to Reading line from file only when there is a new line (live)

Why not take a slightly different approach. Constantly read the file, but only process complete lines. Something like this:

my $buff; my $data; while (1) { if (read(MUFFINLOG, $buf, 1024)) { $data .= $buf; while ($data =~ /\n/) { my $line; ($line, $data) = split /\n/, $data, 2; # process the line of data that is in $line } } }
--
<http://www.dave.org.uk>

Perl Training in the UK <http://www.iterative-software.com>

Replies are listed 'Best First'.
Re: Re: Reading line from file only when there is a new line (live)
by suaveant (Parson) on Sep 12, 2001 at 17:27 UTC
    I believe you need a seek( MUFFINLOG, 0, 1 ); in there to reset the eof... otherwise you won't get newly appended data...

                    - Ant
                    - Some of my best work - Fish Dinner

      me = /s27 ... i get the newly appended data (don't know why ;) - i think i'll use the TAIL thing... sounds good to me. thx alot for all the support.