my $FH; if (exists $attr->{':user_id'}) { $FH = $parser->{parameters}[0]; } else { $FH = $parser->{parameters}[1]; } print $FH $parser->ToXML( $tag, $attr);

The other script works differently. In the '^start_element' handler it resets the flag (stored in $parser->{pad} which is an attribute of the parser specificaly "to put anything you want to and access it in any handler"), then if the <userID> tag is encountered the flag is set and then the 'start_element' handler selects one of the filehandles passed to $parser->parse()