Thanks for this. I just noticed I put "||" in my post instead of "//" which is what I have in my script. I know how they differ but thanks for pointing it out.
I have now figured out it was a combination of using the // operator and also chomp. The code now looks something like:
my $in1 = $ARGV[0]; chomp(my $in2 = $ARGV[1] // ''); if (defined $in1) { $in1 =~ s/\s+//g; # Remove all whitespace instead of chomp if ($in1 =~ /\D+/) { print "Input invalid. Only numbers are allowed\n"; } } else { print "No valid input given\n"; }
In reply to Re^2: Using number "0" as an input argument
by Doozer
in thread Using number "0" as an input argument
by Doozer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |