I have a small Perl script that I need to have the STDIN be numeric, but I need to refer to it as a string also. My script runs, but I get error messages about the strings not being numeric.
my $days = 0;
while ("$days" ne "q")
print "Please enter a single positive integer that represents a n
+umber of days" . , " that you wish to convert into seconds. ,(enter q
+ to quit): ";
if ($days > 0)
my $seconds = $days * 86400;
my $plural = ($days ==1) ? '': 's';
print "\n[$days] day$plural = [$seconds] seconds.\n\n";
elsif ($days < 0)
print "!!! Invalid input. Value must be a positive integer."
elsif ("$days" eq "")
print "!!! You must enter a positive integer.\n\n";
Janitored by Arunbear - added code tags