#!/usr/bin/perl # # $Id: regex-quan-digits 2592 2003-12-21 00:33:01Z jmates $ # # The author disclaims all copyrights and releases this document into # the public domain. # # Test of \d{4} versus \d\d\d\d in regex for speed. use Benchmark qw(cmpthese); #$test = "foo bar 1111 zot"; $test = "this i1s a tes45t of a 234veeeery longi4 string t4o compl32icate matters foo bar 1234 zot"; # test the routines here #&tag; cmpthese( 1000000, { 'short-char' => \&short, 'long-char' => \&long, } ); sub short { $test =~ /\d{4}/; } sub long { $test =~ /\d\d\d\d/; } __END__