@nums = split (' ', $num); my $i = scalar @$items; (warn "invalid items entered, try again\n"), next if grep (/\D/ || $_ < 1 || $_ > $i, @nums);