while ($expect_data =~ /(\d{1,3})/g) { my $next_chunk = $1; # Validate here }