in reply to Parsing a string for sorting

Would this work for you? The validation check would be in a subroutine "is_good".
my $value = "001003051"; my $three; my $start = 0; while ($three = substr $value, $start, 3) { ## Do validation check on $three break unless is_good($three); $start += 3; }