Actually you should check that the argument is defined instead of its truth, you can do either:
my $in1 = defined $ARGV[0] ? $ARGV[0] : ''; or my $in1 = $ARGV[0] // '';, I personally prefer to check that the number of arguments is correct first : my $in = (@ARGV > 0) ? shift : ''; (actually I often check the number of arguments first, so that I can ouput a warning when needed)
Note that after this point, $in1 will always be defined, because an undefined value will be replaced by the empty string (but 0 will be kept as is, and not turned to the empty string as in your code).
I don't know what you do exactly of your input, but I'm not sure you actually need the empty string when your argument is invalid, undef seems to be what you expect. There's of course more than one way to do it, so feel free to adapt this to your needs with a ternary operator, statment modifier or whatever will make this look better to you:
my $input = undef;
if (@ARGV > 0 && $ARGV[0] !~ /\D/)
{
$input = shift;
}
Edit: s/expecy/expect/ as pointed out by MidLifeXis :)