#!/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
In reply to String/Numeric Manipulation by Ms. T.
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |