> TIMTOWTDI: > > @list = grep length==4, /\d+/g Shouldn't that be:
@list = grep length==4, $foo =~ /\d+/g; Cool solution, I wouldn't have thought to do it that way. I'm getting varying Benchmarking results, though. I think it might have something to do with grep speedups from 5.6.1 to 5.8.0... can anyone confirm this? On a box with 4 Xeon 2gigs with 5.6.1 and Benchmark v1: Rate grep wregex regex grep 55586/s -- -13% -23% wregex 64061/s 15% -- -12% regex 72569/s 31% 13% -- But, on another box with 1 AMD 1gig with 5.8.0 and Benchmark v1.0501: Rate wregex regex grep wregex 31437/s -- -14% -18% regex 36470/s 16% -- -5% grep 38212/s 22% 5% -- Confusing! #!/usr/bin/perl -w use strict; use Benchmark qw/cmpthese/; my ($aa); $aa = "1111 2222aa3333 444 55555555 6666 7777-8888"; sub regex { my @aa = $aa =~ /(?<!\d)\d{4}(?!\d)/g } # Wiggins ;-) sub wregex { my @aa = $aa =~ /(?<!\d{4})\d{4}(?!\d{4})/g } sub grep { my @aa = grep length==4, $aa =~ /\d+/g } cmpthese(100000, { regex => \®ex, wregex => \&wregex, grep => \&grep, }); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>