One thing I've learned here at PerlMonks is that unpack can be very fast at this kind of thing:
abaugher@bannor> perl 992848.pl Rate regexit unpackit regexit 133333/s -- -43% unpackit 234432/s 76% -- abaugher@bannor> cat 992848.pl #!/usr/bin/env perl use Modern::Perl; use Benchmark qw(:all); my $p = 'HKTTLDSSRTTTTAABNNRFGHGHGYYH'; cmpthese( 1_000_000, { 'regexit' => \®exit, 'unpackit' => \&unpackit, }); sub regexit { my @p = $p =~ /.{1,3}/g; } sub unpackit { my @p = unpack '(A3)*', $p; }
Aaron B.
Available for small or large Perl jobs; see my home node.
In reply to Re: split function
by aaron_baugher
in thread split function
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |