in reply to Extracting HTML between comments
Should work (although it might have off-by-one problems, and the style might be confusing). Alternately, you could use a separate variable to keep track of your state.while (my $token = $stream->get_token) { if (($token->[0] eq 'C' and $token->[1] eq '<!-- InstanceBeginEditable name="article" -->') .. ($token->[0] eq 'C' and $token->[1] eq '<!-- InstanceEnd -->')) +{ print $token->[1]; } }
my $parsing=undef; while (my $token = $stream->get_token) { if ($token->[0] eq 'C' and $token->[1] eq '<!-- InstanceBeginEditable name="article" -->'){ $parsing=1; } elsif ($token->[0] eq 'C' and $token->[1] eq '<!-- InstanceEnd -->') { $parsing=undef; } elsif ($parsing) { print $token->[1]; } }
|
|---|