package HTML::Zoom::MappedStream;
-use strict;
-use warnings FATAL => 'all';
+use strictures 1;
use base qw(HTML::Zoom::StreamBase);
sub new {
}
sub _next {
- return unless (my $self = shift)->{_source};
+ 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);
}