$in_twig->parsefile('in.xml'); $in_twig = XML::Twig->new( twig_roots => { violation => 1 }, twig_handlers => { violation => sub { processViolation( $in_twig, $_, \%out_twigs, \%opt ); } ); sub processViolation { my $in_twig = shift( @_ ); my $violation = shift( @_ ); my $out_twigs_href = shift( @_ ); my $opt_href = shift( @_ ); printf "Entered subroutine\n"; my $att_waiver = $violation->att('waiver'); if( !defined( $att_waiver ) || ($att_waiver eq "") ) { my $file = ".*/". basename( $violation->att('module') ); my $rule = $violation->att('id'); my $id = join( '.', basename( $violation->att('module') ), $opt_href->{idsid}, $violation->att('key') ); $id =~ s/\s+//g; my $open_date = localtime(); my $waiver = XML::Twig::Elt->new( "waiver", { descr => "", id => $id, owner => $opt_href->{idsid}, rule => $rule, file => $file, key => $violation->att('key'), message => '.*', open_date => $open_date } ); print $waiver->sprint() ."\n"; if( !exists( $out_twigs_href->{$rule} ) ) { $out_twigs_href->{$rule}->{sev} = $violation->att('severity'); $out_twigs_href->{$rule}->{twig} = XML::Twig->new( pretty_print => 'indented' ); $out_twigs_href->{$rule}->{twig}->set_encoding( 'UTF-8' ); $out_twigs_href->{$rule}->{twig}->set_root( XML::Twig::Elt->new( 'LINTRA_WAIVERS' ) ); } $waiver->paste( 'last_child', $out_twigs_href->{$rule}->{twig}->root() ); } $in_twig->purge(); return( 1 ); }