X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FHTML%2FZoom%2FMappedStream.pm;h=75ef2c379c7c4c31c0144bd49a5184b819c07536;hb=1cf035405cb81b780825c083cf7f5c0767b19243;hp=09ef6be85e27a66c192ace41b6e3184c825f5a17;hpb=8a1c87d1e064299bf7f854cc7634b47c4c4cd407;p=catagits%2FHTML-Zoom.git diff --git a/lib/HTML/Zoom/MappedStream.pm b/lib/HTML/Zoom/MappedStream.pm index 09ef6be..75ef2c3 100644 --- a/lib/HTML/Zoom/MappedStream.pm +++ b/lib/HTML/Zoom/MappedStream.pm @@ -1,7 +1,6 @@ package HTML::Zoom::MappedStream; -use strict; -use warnings FATAL => 'all'; +use strictures 1; use base qw(HTML::Zoom::StreamBase); sub new { @@ -12,13 +11,15 @@ sub new { }, $class); } -sub next { - return unless (my $self = shift)->{_source}; +sub _next { + my ($self, $am_peek) = @_; + return unless $self->{_source}; # If we were aiming for a "true" perl-like map then we should # elegantly handle the case where the map function returns 0 events # and the case where it returns >1 - if you're reading this comment # because you wanted it to do that, now would be the time to fix it :) - if (my ($next) = $self->{_source}->next) { + if (my ($next) = $self->{_source}->${\($am_peek ? 'peek' : 'next')}) { + $self->{_peeked_from} = $next if $am_peek; local $_ = $next; return $self->{_mapper}->($next); }