- my $filter = $self->{filter};
- return if $filter == -1; # last call was EOF
-
- my $buf = delete $self->{buf}; # initial buffer
- $buf = $self->{rpipe}->getline unless defined $buf;
- $self->{filter} = -1 unless defined $buf; # set EOF for next call
- $filter ? $filter->($buf) : $buf;
+ my $rpipe = $self->{rpipe} or return; # EOF was set on previous call
+ my $buf = delete($self->{initial_buf}) // $rpipe->getline;
+ delete($self->{rpipe}) unless defined $buf; # set EOF for next call
+ if (my $filter = $self->{filter}) {
+ $buf = $filter->translate($buf);
+ }
+ $buf;