Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: 4f21b5dd07
Fetching contributors…

Cannot retrieve contributors at this time

40 lines (32 sloc) 0.746 kB
use strict;
use warnings;
use POE qw[Wheel::ReadWrite];
$|=1;
my $file = shift or die "Please specify a file to read\n";
POE::Session->create(
package_states => [
'main' => [qw(_start _input _error)],
],
);
$poe_kernel->run();
exit 0;
sub _start {
open my $fh, '<', $file or die "$!\n";
$_[HEAP]->{file} = POE::Wheel::ReadWrite->new(
Handle => $fh,
InputEvent => '_input',
ErrorEvent => '_error',
);
return;
}
sub _input {
my ($heap, $input, $wheel_id) = @_[HEAP, ARG0, ARG1];
print "$input\n";
return;
}
sub _error {
my ($operation, $errnum, $errstr, $id) = @_[ARG0..ARG3];
warn "Wheel $id encountered $operation error $errnum: $errstr\n";
delete $_[HEAP]{file}; # shut down that wheel
return;
}
Jump to Line
Something went wrong with that request. Please try again.