in reply to Re: Using number "0" as an input argument
in thread Using number "0" as an input argument
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"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Using number "0" as an input argument
by RonW (Parson) on Sep 22, 2015 at 17:37 UTC | |
|
Re^3: Using number "0" as an input argument
by SuicideJunkie (Vicar) on Sep 22, 2015 at 14:54 UTC |