X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FHTML%2FZoom%2FFilterStream.pm;h=89605dd7c8b014261e6dcb2ae80810d768cd0a89;hb=8f9628843b59b74bb8f8936460fb8676c410c35f;hp=c69815969123fe1024c8e3fcce0e057c0890eb93;hpb=41153e878cdf40d366ccee57716acd49f26733b1;p=catagits%2FHTML-Zoom.git diff --git a/lib/HTML/Zoom/FilterStream.pm b/lib/HTML/Zoom/FilterStream.pm index c698159..89605dd 100644 --- a/lib/HTML/Zoom/FilterStream.pm +++ b/lib/HTML/Zoom/FilterStream.pm @@ -15,9 +15,26 @@ sub new { ); } +sub peek { + my ($self) = @_; + if (exists $self->{_peeked}) { + return ($self->{_peeked}); + } + if (my ($peeked) = $self->next) { + return ($self->{_peeked} = $peeked); + } + return; +} + sub next { my ($self) = @_; + # peeked entry so return that + + if (exists $self->{_peeked}) { + return (delete $self->{_peeked}); + } + # if our main stream is already gone then we can short-circuit # straight out - there's no way for an alternate stream to be there