use strict; use warnings; use Benchmark qw( cmpthese ); my $string = '1234 this is the remaining string'; cmpthese( -5, { unpack => sub { unpack( 'A4xA*', $string ) }, regex => sub { $string =~ m[(\d+)\s+(.*)$] }, split => sub { split( /(\d+)\s+/, $string, 2 ) }, } );