add strictures commit (out of order)
[catagits/HTML-Zoom.git] / lib / HTML / Zoom / MappedStream.pm
index 7d0c505..75ef2c3 100644 (file)
@@ -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 {
@@ -13,12 +12,14 @@ 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);
   }