Perl Performance Considerations
Published on 30 May 2007Tags #Perl #RegEx
As stated earlier in avoiding regular expressions, it may beneficial to avoid regexes to improve performance. The following code demonstrates five different ways to split a string.
my $data = 'blarg test';
my @fields = split(' ', $data);
my @fields = split(/s/, $data);
my @fields = ($data =~ m/^(\S+)\s+(\S+)$/);
my @fields = unpack 'A5xA4', $data;
See also: Avoiding regular expressions