use strict; use warnings; my $string = '1234 this is the remaining string'; # A4 = take the first 4 ASCII characters # x = skip the next byte # A* = take all remaining ASCII characters my ( $num, $text ) = unpack( 'A4xA*', $string ); print "[$num][$text]\n";