in reply to Re: Chew before you swallow
in thread Chew before you swallow

Sub-class IO::File and you've already got it. Should be a no-brainer.
#!/usr/bin/perl -w package IO::File::AutoChomp; use base 'IO::File'; sub getline { my ($self) = @_; # Awkward, I know. return (map { chomp; $_ } $self->SUPER::getline())[0]; } sub getlines { my ($self) = @_; return map { chomp; $_ } $self->SUPER::getlines(); } package main; my $fh = IO::File::AutoChomp->new_from_fd(*DATA, "r") || die "Could no +t open DATA\n"; print join(",", $fh->getlines()); $fh->close(); __END__ The wily rat ate the last donut.