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/((?:\s*(?:.{1,$short_line_threshold})<\/line>\s*){$short_line_counter,})(\s*(?:.{$long_line_threshold,}?)<\/line>)/$1<\/para>$2/gs; print $t->report();