sub start { return if $stack[-1][0] eq 'cfif' and $tag ne 'cfelse' and not istrue($stack[-1][1]); return if $stack[-1][0] eq 'cfelse' and istrue($stack[-2][1]); } sub end { return if $stack[-1][0] eq 'cfif' and $tag ne 'cfif' and not istrue(...); return if $stack[-1][0] eq 'cfelse' and istrue(...); } sub text { something like what i used in start() }