#!/usr/bin/perl -w # $Id: bench_twig_complex,v 1.3 2003/09/19 18:52:26 mrodrigu Exp $ use strict; use simple_benchmark; # to get memory size use XML::Twig; use Getopt::Long; my( $in_file, $print); GetOptions( 'print!' => \$print, 'in_file=s' =>\$in_file); $in_file ||= 'test.xml'; $print = 1 unless( defined $print); my $message_nb= 0; my $t= XML::Twig->new( twig_handlers => { q{process[@action="delete"]} => sub { $_->delete }, q{process[@action="duplicate"]} => sub { $_->copy->paste( before => $_) }, q{process[@action="change_tag"]} => sub { $_->set_tag( 'new_tag') }, q{process[@action="prefix"]} => sub { $_->insert_new_elt( first_child => 'prefix', "prefixed ") }, q{process[@action="add_att"]} => sub { $_->set_att( new_att => "foo") }, q{process[@action="erase"]} => sub { $_->erase }, }, ) ->parsefile( $in_file); $t->print if( $print);