#!/usr/bin/perl -w # $Id: bench_regexp_complex,v 1.3 2003/09/19 18:52:26 mrodrigu Exp $ use strict; use simple_benchmark; # to get memory size use File::Slurp; use Getopt::Long; my( $in_file); GetOptions( 'in_file=s' =>\$in_file); $in_file ||= 'test.xml'; my $xml = read_file( $in_file); # first expand empty process tags, or it the following regexps become a lot more complex $xml=~ s{(]*) />}{$1>}gx; $xml=~ s{]* action \s* = \s* "delete" [^>]*>.*?} {}gx; $xml=~ s{(]* action \s* = \s* "duplicate" [^>]*>.*?)} {$1$1}gx; $xml=~ s{]* action \s* = \s* "change_tag" [^>]*>.*?)} {}gx; $xml=~ s{(]* action \s* = \s* "prefix" [^>]*>)} {$1prefixed }gx; $xml=~ s{(]*) (action \s* = \s* "add_att" [^>]*>)} {$1 new_att="foo" $2}gx; $xml=~ s{]* action \s* = \s* "erase" [^>]*>(.*?)} {$1}gx; print $xml;