in reply to Re^3: Net::IRC and File::Tail
in thread Net::IRC and File::Tail

Hm. This might explain the lack of action when I us the "tie" example
I will try this instead, but I am currently getting an error message when I run that code
I'll try to work it out though..
erromsg:
Can't use an undefined value as filehandle reference at ./unixfh line 4.
#!/usr/bin/perl -w use strict; my $logfile= "./totte.log"; open my $log, "| -", 'tail', '-f', $logfile or die "Couldn't read logf +ile '$logfile': $!";

Replies are listed 'Best First'.
Re^5: Net::IRC and File::Tail
by Corion (Patriarch) on Aug 16, 2007 at 10:26 UTC

    My code is different from your code. My code works. I test it as follows:

    #!/usr/bin/perl -w my $logfile = "./totte.log"; open my $log, '-|', qw(tail -f), $logfile or die "Couldn't tail logfile '$logfile': $!"; while (<$log>) { chomp; print "Got line >>$_<<\n"; };

    Note the order and the lack of whitespace in the second argument to open.

    The whole console session is:

    osabst@dfrsifc1:/tmp $ cat >totte.log test osabst@dfrsifc1:/tmp $ perl -w tmp.pl Got line >>test<<

    This is where I add another line to the logfile from another session

    Got line >>test2<< $ cat tmp.pl #!/usr/bin/perl -w my $logfile = "./totte.log"; open my $log, '-|', qw(tail -f), $logfile or die "Couldn't tail logfile '$logfile': $!"; while (<$log>) { chomp; print "Got line >>$_<<\n"; };
      When I still could not get this to work as you verified
      I did check the perl version on the box im using... 5.6 !
      When I tested the code on a 5.8 version it rocked, so it's upgrade time
      . Thanks all for now, and I'll let you know later how it goes.