jadams has asked for the wisdom of the Perl Monks concerning the following question:

Dear monks, as a replacement for the tail command on Windows (File::Tail doesn't work for Win32 implemetations) I tried Wheel::FollowTail from POE. To handle failures, a simple error routine is called if e.g the file "tailed" is shortend (for some reason). In case of an error, the watcher should be shut down. I ran the code in debug mode an found that no session information (wheel id, service) is available! To double check this behaviour, I tested the code with ActiveState and Strawberry Perl with same results.
POE version: 1.292 (latest) ActiveState Perl : perl 5, version 12, subversion 0 (v5.12.0) built fo +r MSWin32-x86-multi-thread, ActivePerl Build 1200 [292396], Built und +er MSWin32, Compiled at Apr 11 2010 11:30:56 Strawberry Perl: perl 5, version 12, subversion 0 (v5.12.0) built for +MSWin32-x86-multi-thread, strawberryperl 5.12.0.1 #1 Thu May 6 16:09 +:27 2010 i386, Built under MSWin32, Compiled at May 6 2010 16:31:59
The code is adopted from POE web site http://poe.perl.org/?POE_Cookbook/Watching_Logs.
#!/usr/bin/perl -w # Got from http://poe.perl.org/?POE_Cookbook/Watching_Logs use POE qw/Wheel::FollowTail/; use strict; $| = 1; my $filename = $ARGV[0]; my $filesize_after = -s "$filename"; die "Usage: $0 <filename>\n" unless $filename; die "$0: $filename: No such file or directory\n" unless -e $filename; die "$0: $filename: Permission denied\n" unless -r $filename; POE::Session->create ( inline_states => { _start => sub { $_[HEAP]->{wheel} = POE::Wheel::FollowTail->new( Filename => $_[ARG0], InputEvent => 'got_line', ErrorEvent => 'got_error', PollInterval => 1, ); $_[HEAP]->{first} = 0; }, got_line => sub { print "$_[ARG0]\n" if $_[HEAP]->{first}++ }, got_error => \&handle_log_error, }, args => [$filename], ); # Handle log errors to shut down the service. sub handle_log_error { my ($heap, $operation, $errno, $error_string, $wheel_id) = @_[HEAP, ARG0, ARG1, ARG2, ARG3]; my $service = $heap->{services}->{$wheel_id}; print "--- $service log $operation error $errno: $error_string\n"; print "--- Shutting down $service log watcher.\n"; delete $heap->{services}->{$wheel_id}; delete $heap->{watchers}->{$wheel_id}; } sub print_tail { my ($heap, $line) = @_[HEAP, ARG0]; my $filesize = -s "$heap->{wheel}->[1]"; if ( $filesize >= $filesize_after) { print "$line\n" if $_[HEAP]->{first}++; } else { handle_file_error(); } $filesize_after = -s "$heap->{wheel}->[1]"; } $poe_kernel->run();
Has anybody an idea what went wront/I did wrong? Any comments are welcome (this issue is driving me nuts 8).

Thanks a lot,
Juergen