http://www.perlmonks.org?node_id=397367

Ms. T. has asked for the wisdom of the Perl Monks concerning the following question:

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.
#!/bin/perl -w use strict; 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): "; $days=<STDIN>; chomp $days; 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"; } } print "Goodbye\!\n\n";

Janitored by Arunbear - added code tags