#!/usr/bin/perl -w use strict; use vars qw(@myvar $iteration); use Benchmark; @myvar = ('asdf"' . 'z' x 2000 . '"asdf', 'z' x 2000 . '"asdf"', '"asdf"' . 'z' x 2000, 'z' x 2000 . '"' . 'z' x 2000 . '"' . 'z' x 2000 ); for $iteration (0 .. (@myvar-1)) { print "Iteration: $iteration\n"; timethese(500000, { Greedy => '$myvar[$iteration] =~ /".+"/', Negated => '$myvar[$iteration] =~ /"[^"]+"/' }); }; Iteration: 0 Benchmark: timing 500000 iterations of Greedy, Negated... Greedy: 13 wallclock secs (13.84 usr + 0.00 sys = 13.84 CPU) Negated: 50 wallclock secs (49.99 usr + 0.00 sys = 49.99 CPU) Iteration: 1 Benchmark: timing 500000 iterations of Greedy, Negated... Greedy: 18 wallclock secs (17.68 usr + 0.00 sys = 17.68 CPU) Negated: 17 wallclock secs (17.02 usr + 0.00 sys = 17.02 CPU) Iteration: 2 Benchmark: timing 500000 iterations of Greedy, Negated... Greedy: 46 wallclock secs (46.75 usr + 0.00 sys = 46.75 CPU) Negated: 2 wallclock secs ( 1.92 usr + 0.00 sys = 1.92 CPU) Iteration: 3 Benchmark: timing 500000 iterations of Greedy, Negated... Greedy: 73 wallclock secs (73.60 usr + 0.00 sys = 73.60 CPU) Negated: 65 wallclock secs (64.97 usr + 0.00 sys = 64.97 CPU)