use strict; use warnings; use 5.010; $_ = '79899920179'; my $pass = qr/(?=)/; my $fail = qr/(*FAIL)/; while (/\G(\d{2,}?)(??{ $1 >= 32 ? $pass : $fail })/g) { say $1; }