Among the activities which can help you to understand more are:
- use strict; use warnings; they're there to help you find typos and other mistakes. Generally, they're a new Perl programmers 2nd best friend (in line right behind perldoc [-c function] | &$91;module&93;) and in this case, were you to replace your printf statement with three separate print statements you'd discovered some problems.
- Next time, READ the instructions around the text box where you enter your node). Where you a registered user you could see those instructions immediately below the rendered text were you to re-visit another of the nodes created after registering.
- Consider why you have chose to multiply 1*60 and to calculate 60%60 (Hint 1: one times anything is what? Hint 2: anything modulus itself is what?).
Run this (it's --mostly-- not a 'how-to' but rather an illustration of 'how-not-to-do-it.'); chew on what you see as output for a bit:
(mostly) BAAAD CODE!
#!/usr/bin/perl
use 5.016; # implicit use strict; with recent vers
+ions of perl
use warnings;
# 1060823
my $countdown = 1*60; # 60 seconds
$| = 1; # disable output buffering
my $start_time = time; # use the time function (see perldoc -
+f time)
say "\t \$start_time: $start_time";
my $end_time = $start_time + $countdown;
for (;;) { # empty for clause
my $time = time;
say $time;
last if ($time >= $end_time);
# printf("\r%02d:%02d:%02d", ($end_time - $time) / (1*60); ($end_t
+ime - $time) / 60%60, ($end_time - $time) % 60);
say "Ln 19: " . (($end_time - $time) / (1*60));
say " Ln 20: " . (($end_time - $time) / 60%60);
say " Ln 23: " .(($end_time - $time) % 60);
sleep(1);
}
Questions? C'mon back with those you can't answer for yourself from the relevant documents, Tutorials here, etc. You'll get quick and friendly responses.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.