Salutations, and apologies for the giant reply-all.

Paul Johnson wrote:

> No.  But it might be if autodie could be persuaded to work on an implicit
> close when a lexical filehandle goes out of scope.  That is, if these two
> snippets functioned identically:
> 
>  $ perl5.12.2 -Mautodie -E 'open my $f, ">", "/dev/full"; print $f 23'
>  $ perl5.12.2 -Mautodie -E 'open my $f, ">", "/dev/full"; print $f 23; close 
> $f'
> 
> Anyone know what it would take to get that to work?

The most straightforward way I can think of would be to have autodie turn
the filehandle into an object before returning it.  The object can then
check for a successful close when it falls out of scope.

Fatal::_one_invocation is the most likely place for such code to be
inserted, it already has special cases for system() and flock().

The problem is that this isn't lexical scope, which autodie otherwise
strictly adheres to.  You could quite happily return the new filehandle, and
it will still check for a successful close when it's finally destroyed, even
if autodie is no longer in effect.  That's definitely action from a distance.

p5p - any opinions on this either way?

Best wishes,

        Paul

-- 
Paul Fenwick <p...@perltraining.com.au> | http://perltraining.com.au/
Director of Training                   | Ph:  +61 3 9354 6001
Perl Training Australia                | Fax: +61 3 9354 2681

Reply via email to