while (1) { my @matches = $self->{buffer} =~ $compiled; if ($End_Of_String or not @matches) { $End_Of_String = 0; return undef unless $self->fill_buffer(); next; } else { my $index = undef; for ( 0 .. $#matches ) { $index = $_, last if defined $matches[$_]; } die if not defined $index; # sanity check my $match = $matches[$index]; $self->{buffer} =~ s/^(.*?)\Q$match\E//s or die; return ( $1, $match ); } } }