in reply to Re: Re: Profiling regular expressions
in thread Profiling regular expressions
I tried it on the following simple case, and it worked.package Filt; use Filter::Simple; FILTER { my @set = split /\n/,$_; my $new = ''; foreach my $line (@set) { if ($line =~ /\=\~/) { $new .= "\$t->start('$line');\n"; $new .= $line . "\n"; $new .= "\$t->stop();\n"; } else { $new .= $line . "\n"; } } $_ = $new; }; 1 ;
use strict; use Benchmark::Timer; use Filt; our $t = Benchmark::Timer->new(); my $short_line_threshold = 2; my $short_line_counter = 1; my $long_line_threshold = 7; my $tmp = "Abcdef"; $tmp =~ s/((?:<line>\s*(?:.{1,$short_line_threshold})<\/line>\s*){$sho +rt_line_counter,})(<line>\s*(?:.{$long_line_threshold,}?)<\/line>)/$1 +<\/para><para>$2/gs; print $t->report();
|
|---|