#!/usr/bin/perl -w # $Id: bench_dt_complex,v 1.2 2003/10/10 16:09:48 mrodrigu Exp $ use strict; use XML::DT; use simple_benchmark; # to get memory size # This is the simple version 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 %commands = ( delete => sub { "" }, prefix => sub { my ($q,$c,%v) = @_; $_[1] = "prefixed $c"; # hackish toxml }, duplicate => sub { my ($q,$c,%v) = @_; toxml.toxml }, change_tag => sub { my ($q,$c,%v) = @_; $_[0] = 'new_tag'; # hackish toxml }, erase => sub { my ($q,$c) = @_; $c }, add_att => sub { my ($q,$c,%v) = @_; $v{new_att} = "foo"; toxml ($q,\%v,$c); # proper way } ); my $result = pathdt($in_file, '//process[@action]' => sub { &{$commands{$v{action}}}($q,$c,%v) }); print $result if $print;