in reply to Formatting in Perl
You didn't show us any code that might give us some indication as to what you're doing wrong. You should post somewhere less than ten lines of code (in this case) that mimicks the problem. (10 is an arbitrary number, but for such a simple problem is probably sufficient).
If you want me to guess, I'll say your problem is that you are accepting the number of days as input, and forgetting to chomp that input. When the user types "1<enter>", that is captured into the recipient variable as "1\n" (in other words, enter is preserved as a \n (newline) character). chomp the input and the problem will go away, if my guess as to what you are doing wrong is correct.
As for figuring out how to print all that:
print "[$days] day", ($days != 1) ? 's' : '', ' = [', $days * 24 * 60 * 60, "] seconds.\n";
...should do the trick.
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Formatting in Perl
by tachyon (Chancellor) on Oct 01, 2004 at 03:28 UTC | |
by Ms. T. (Novice) on Oct 01, 2004 at 21:01 UTC | |
by TrekNoid (Pilgrim) on Oct 01, 2004 at 21:18 UTC |