in reply to Stumped with select->can_read
For example:
my $sel= ...; my $bytes= 16*1024; my %buf; my @ready; while( @ready= $sel->can_read() ) { foreach my $fh ( @ready ) { for my $buf ( $buf{$fh} ) { $buf = '' if ! defined $buf; my $eof= ! sysread( $fh, $buf, $bytes, length($buf) ); while( $buf =~ s/^(.*\n)// || $eof && $buf =~ s/^(.+)$// ) { my $line = $1; if( $line =~ /keyword/ ) { print REDUCEDLOG $line; } } } } }
- tye
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Stumped with select->can_read (example)
by w1r3d (Initiate) on Aug 06, 2012 at 16:07 UTC | |
by tye (Sage) on Aug 06, 2012 at 17:22 UTC | |
by w1r3d (Initiate) on Aug 06, 2012 at 18:42 UTC |