# this code is missing a lot. don't expect it to work :) { my @stack; sub start { push @stack, $tag; } sub end { if ($tag eq 'cfif' and $stack[-1] eq 'cfelse'){ pop @stack; } die "Invalid code" if pop(@stack) ne $tag; } sub text { # use @stack to determine where we are... } } my $parser = HTML::Parser->new(start_h => [\&start, 'tagname'], end_h => [\&end, 'tagname'], text => [\&text, 'text'], ); $parser->report_tags(qw/cfif cfelse cfend/); $parser->parse($cfml); #### foobar ==> text ''; start 'cfif'; text 'foo'; start 'cfelse'; text 'bar'; end 'cfif'; #### 2;0 juerd@ouranos:~$ perl -e'undef christmas' Segmentation fault 2;139 juerd@ouranos:~$