while ($raw =~ /\G([\w ]*)/g) { $scrubbed .= $1; my $pos = pos($raw); if ($raw =~ /\G($is_handled)/g) { $scrubbed .= $handler->{ lc($1) }->(\$raw); # See perlre. If the handler matches something of # length 0, it won't match something of length 0 # the next time through. So... pos($raw) = pos($raw); } unless (pos($raw)) { if (length($raw) == $pos) { # EXIT HERE # return $scrubbed . $handler->{post}->(\$raw); } else { my $char = substr($raw, $pos, 1); pos($raw) = $pos + 1; $scrubbed .= &encode_entities($char); } } } #### sub { my $t_ref = shift; if ($$t_ref =~ /\G( *)/g) { my $indent = $1; $indent =~ s/ / /g; return "
\n$indent"; } else { confess("This shouldn't happen"); } }