#!perl use strict; use warnings; while () { chomp($_); print "$_ okay\n" if /^(\d)((??{$+ + 1}))+$/; } __DATA__ 234 213 12345