Gregory Machin am Mittwoch, 13. Dezember 2006 12:08:
> Hi
Hello Gregory
> please could you have a look and see what I have missed.
use strict;
use warnings;
# and declare variables with 'my' where missed
> use File::Tail;
> my $name="/etc/openvpn/logs/CT-NET.log";
my $name='/etc/openvpn/logs/CT-NET.log';
> my $maxinterval=10 ;
> my $adjustafter=7 ;
>
> $file=File::Tail->new(name=>$name, maxinterval=>$maxinterval,
> adjustafter=>$adjustafter);
> while (defined($line=$file->read)) {
> print ("$line"); << this line prints fine
print $line;
> print ("hello"); << but this one does not print at all
>
> }
>
> i have allso tried print "hello"; but the result is the same..
> I have tried ping ("$line hello"); but it does not print the hello.
>
> what have I missed ..
This is an buffering issue; normally, the output buffer is only flushed if it
contains enough data (to fill the entire buffer), after a line end is printed
to the buffer, or if the program ends (then buffers are flushed before file
handles are closed).
This has nothing to do with File::Tail; the following code will also not
print 'hello' (until it ends after 10 seconds):
print 'hello';
sleep 10;
What you can do:
1. append a "\n" to "hello":
print ("hello\n");
2. setting the $| variable to a true value, for example with:
{
local $|=1;
print ('hello'); # original line; note single quotes
}
See perldoc perlvar for the $| variable
Hope this helps!
Dani
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>