in reply to Re^4: Perl jumps to END logic after fileno (Win32)
in thread Perl jumps to END logic after fileno (Win32)
Since the scalar is scoped to the scope of the subroutine and the thread logic was outside of that function I was attempting to pass the handle as an argument to the thread, which fails in various ways.
Hi, to me it seems like it works the same way, just no globals or no closures
#!/usr/bin/perl -- use strict; use warnings; use autodie qw/ open close /; use threads stack_size => 4096; { open my $fh, '<', __FILE__; threads->create(\&close_once, $fh )->join; threads->create(\&close_twice, $fh )->join; close $fh; close $fh; ## 11 } sub close_once { my( $fh ) = @_; close $fh; } sub close_twice { my( $fh ) = @_; close $fh; eval { close $fh; 1 } or warn $@; ## 20 return; } __END__ Can't close(GLOB(0xc38d6c)) filehandle: 'Bad file descriptor' at threa +ds-close-filehandle-LEXICAL.pl line 20 Can't close(GLOB(0x99b26c)) filehandle: 'Bad file descriptor' at threa +ds-close-filehandle-LEXICAL.pl line 11
|
|---|