#!/usr/local/bin/perl -w use strict; while (1) { print "Please enter a single positive integer that represents a number of days, that you wish to convert into seconds. ,(enter q to quit): "; chomp (my $days = ); $days =~ s/\+//; # allow them to enter +12 if ($days eq "q") { last; } elsif (($days =~ /[^\d]/) or ($days eq "")) { # days contains an non digit character or is empty print "\n!!! You must enter a positive integer.\n\n"; } else { my $seconds = $days * 86400; my $plural = ($days == 1) ? '' : 's'; print "\n$days day$plural = $seconds seconds.\n\n"; } } print "Goodbye\!\n\n";