I'd like to see some state added to a IO::File object. something that
permits you tell if the file existed when you opened it, and what its
original name is. Here is an old subclass of IO::File that does it. I
was thinking about subclasses IO::Moose::File and adding this, if you
don't want to add to core.
use strict;
use warnings;
use base 'IO::File';
use feature ':5.10';
my %data;
sub previouslyCreated {
$data{+shift}->{existed_when_opened}
}
sub originalLoc {
$data{+shift}->{original_location}
}
sub new {
my ( $class, @args ) = @_;
my $exists = -e $args[0] ? 1 : 0;
my $self = $class->SUPER::new( @args );
$data{$self} = {
existed_when_opened => $exists
, original_location => $args[0]
};
$self;
};