[url=http://perldoc.perl.org/functions/use.html][black][b]use[/b][/black][/url] [green]HTML::Parser[/green][red];[/red]
[black][b]use[/b][/black] [green]strict[/green][red];[/red]
[url=http://perldoc.perl.org/functions/my.html][black][b]my[/b][/black][/url] [blue]@start_cond[/blue] = [red]([/red]
[red]{[/red][purple]event[/purple] => [red]'[/red][purple]start[/purple][red]'[/red], [purple]tagname[/purple] => [red]'[/red][purple]h2[/purple][red]'[/red][red]}[/red],
[red]{[/red][purple]event[/purple] => [red]'[/red][purple]text[/purple][red]'[/red], [purple]text[/purple] => [red]'[/red][purple]Basic details for:[/purple][red]'[/red][red]}[/red],
[red]{[/red][purple]event[/purple] => [red]'[/red][purple]end[/purple][red]'[/red], [purple]tagname[/purple] => [red]'[/red][purple]h2[/purple][red]'[/red][red]}[/red],
[red])[/red][red];[/red]
[black][b]my[/b][/black] [blue]@end_cond[/blue] = [red]([/red]
[red]{[/red][purple]event[/purple] => [red]'[/red][purple]comment[/purple][red]'[/red], [purple]text[/purple] => [red]'[/red][purple]<!-- MIFID Changes -->[/purple][red]'[/red][red]}[/red],
[red])[/red][red];[/red]
[black][b]my[/b][/black] [blue]$html[/blue] = [url=http://perldoc.perl.org/functions/do.html][black][b]do[/b][/black][/url] [red]{[/red][url=http://perldoc.perl.org/functions/local.html][black][b]local[/b][/black][/url] [blue]$/[/blue][red];[/red] <DATA>[red]}[/red][red];[/red]
[black][b]my[/b][/black] [blue]$p[/blue] = HTML::Parser->[maroon]new[/maroon][red]([/red]
[purple]default_h[/purple] => [red][[/red]\[maroon]&start_h[/maroon], [red]"[/red][purple]self,event,text,tagname[/purple][red]"[/red][red]][/red],
[red])[/red][red];[/red]
[blue]$p[/blue]->[maroon]parse[/maroon][red]([/red][blue]$html[/blue][red])[/red][red];[/red]
[url=http://perldoc.perl.org/functions/print.html][black][b]print[/b][/black][/url] [red]"[/red][purple][blue]$p[/blue]->{_text}[/purple][red]"[/red][red];[/red]
[gray][i]######[/i][/gray]
[gray][i]# Supporting Functions[/i][/gray]
[url=http://perldoc.perl.org/functions/sub.html][black][b]sub[/b][/black][/url] [maroon]match_sequential_condition[/maroon] [red]{[/red]
[black][b]my[/b][/black] [red]([/red][blue]$condsref[/blue], [blue]$self[/blue], [blue]$event[/blue], [blue]$text[/blue], [blue]$tagname[/blue][red])[/red] = [blue]@_[/blue][red];[/red]
[black][b]my[/b][/black] [blue]$condition[/blue] = [blue]$condsref[/blue]->[red][[/red][blue]$self[/blue]->[red]{[/red]_condition_index[red]}[/red] ||= [fuchsia]0[/fuchsia][red]][/red][red];[/red]
[black][b]my[/b][/black] [blue]%token[/blue] = [red]([/red][purple]event[/purple] => [blue]$event[/blue], [purple]text[/purple] => [blue]$text[/blue], [purple]tagname[/purple] => [blue]$tagname[/blue][red])[/red][red];[/red]
[black][b]my[/b][/black] [blue]$is_match[/blue] = [fuchsia]1[/fuchsia][red];[/red]
[maroon]TEST[/maroon][maroon]:[/maroon]
[olive][b]while[/b][/olive] [red]([/red][black][b]my[/b][/black] [red]([/red][blue]$key[/blue], [blue]$val[/blue][red])[/red] = [url=http://perldoc.perl.org/functions/each.html][black][b]each[/b][/black][/url] [blue]%$condition[/blue][red])[/red] [red]{[/red]
[olive][b]if[/b][/olive] [red]([/red]! [url=http://perldoc.perl.org/functions/exists.html][black][b]exists[/b][/black][/url] [blue]$token[/blue][red]{[/red][blue]$key[/blue][red]}[/red] || [blue]$token[/blue][red]{[/red][blue]$key[/blue][red]}[/red] ne [blue]$val[/blue][red])[/red] [red]{[/red]
[blue]$is_match[/blue] = [fuchsia]0[/fuchsia][red];[/red]
[olive][b]last[/b][/olive] TEST[red];[/red]
[red]}[/red]
[red]}[/red]
[olive][b]if[/b][/olive] [red]([/red][blue]$is_match[/blue][red])[/red] [red]{[/red]
[blue]$self[/blue]->[red]{[/red]_condition_index[red]}[/red]++[red];[/red]
[blue]$self[/blue]->[red]{[/red]_condition_index[red]}[/red] %= [blue]@$condsref[/blue][red];[/red]
[blue]$is_match[/blue] = [fuchsia]0[/fuchsia] [olive][b]if[/b][/olive] [blue]$self[/blue]->[red]{[/red]_condition_index[red]}[/red][red];[/red] [gray][i]# Still more tests[/i][/gray]
[red]}[/red] [olive][b]else[/b][/olive] [red]{[/red]
[blue]$self[/blue]->[red]{[/red]_condition_index[red]}[/red] = [fuchsia]0[/fuchsia][red];[/red]
[red]}[/red]
[url=http://perldoc.perl.org/functions/return.html][black][b]return[/b][/black][/url] [blue]$is_match[/blue][red];[/red]
[red]}[/red]
[black][b]sub[/b][/black] [maroon]start_h[/maroon] [red]{[/red]
[black][b]my[/b][/black] [red]([/red][blue]$self[/blue], [blue]$event[/blue], [blue]$text[/blue], [blue]$tagname[/blue][red])[/red] = [blue]@_[/blue][red];[/red]
[olive][b]if[/b][/olive] [red]([/red][maroon]match_sequential_condition[/maroon][red]([/red]\[blue]@start_cond[/blue], [blue]@_[/blue][red])[/red][red])[/red] [red]{[/red]
[blue]$self[/blue]->[maroon]handler[/maroon][red]([/red][purple]default[/purple] => \[maroon]&end_h[/maroon], [red]"[/red][purple]self,event,text,tagname[/purple][red]"[/red][red])[/red][red];[/red]
[blue]$self[/blue]->[red]{[/red]_text[red]}[/red] = [red]'[/red][purple][/purple][red]'[/red][red];[/red]
[red]}[/red]
[red]}[/red]
[black][b]sub[/b][/black] [maroon]end_h[/maroon] [red]{[/red]
[black][b]my[/b][/black] [red]([/red][blue]$self[/blue], [blue]$event[/blue], [blue]$text[/blue], [blue]$tagname[/blue][red])[/red] = [blue]@_[/blue][red];[/red]
[black][b]return[/b][/black] [blue]$self[/blue]->[maroon]eof[/maroon][red]([/red][red])[/red] [olive][b]if[/b][/olive] [maroon]match_sequential_condition[/maroon][red]([/red]\[blue]@end_cond[/blue], [blue]@_[/blue][red])[/red][red];[/red]
[blue]$self[/blue]->[red]{[/red]_text[red]}[/red] .= [blue]$text[/blue][red];[/red]
[red]}[/red]
[fuchsia]1[/fuchsia][red];[/red]
[teal]__DATA__[/teal]
[teal]<html>[/teal]
[teal]<body>[/teal]
[teal]<h2>Basic details for:</h2>[/teal]
[teal]Main content here.[/teal]
[teal]no really.[/teal]
[teal]<!-- MIFID Changes -->[/teal]
[teal]</body>[/teal]
[teal]</html>[/teal]