my ($number, $ok) = (1234, undef);
$number =~ s/^(\d+)$/$ok = ($1 >= 123 and $1 <= 4567) ? 1 : 0/e;
printf qq|%s\n|, $ok ? 'OK': 'NG';