package IO::File::Stateful; use Class::InsideOut qw/public register id/; use base 'IO::File'; public 'input_record_separator' => my %IRS; sub new { my $class = shift; my $self = IO::File->new(@_); register( $self, $class ); $IRS{ id $self } = $/; # at time of creation return $self; } sub getline { my $self = shift; local $/ = $IRS{ id $self }; return $self->SUPER::getline(); } 1;