Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Simple Greeter (well, it's a start)

by grinder (Bishop)
on Apr 30, 2003 at 21:40 UTC ( [id://254490]=note: print w/replies, xml ) Need Help??


in reply to Simple Greeter

By visual inspection I can see a number of errors.

use strict is lacking a semicolon. If you mean to use strictures then you must predeclare all your variables as either package variables (with use vars) or lexical variables (with my).

There is a big conceptual problem with calling localtime repeatedly. What happens if you make the individual calls at the exact moment when the minute, hour, day... wraps around? Instead of getting 4:59:59, you might wind up with 5:00:59. localtime will return an array. Call it once and save the result as an array and then pick out what you want, rather than calling it repeatedly and carving out what you want with array slices.

To zero fill a value, as you do for the minutes, it's much simpler to write $min = sprintf('%02d', $min). Saying $min = $min is what's known as a nop.

Other than that, you're off to a good start. Keep it up, and read as much code by other people as you can.

____________________________________________________________
Join the monks coming to YAPC::Europe 2003 in Paris, 23-25 July 2003.

Replies are listed 'Best First'.
Re: Re: Simple Greeter (well, it's a start)
by harley_frog (Novice) on May 01, 2003 at 14:24 UTC
    Thanks for the input. I did notice the missing semi-colon after  use strict last night and made the correction. (Must have deleted it while demoing it to a friend. (don't ask))

    Thanks, too, for the heads up on the  localtime. I figured there had to be a better way, but considering that I started this last Friday and I only started reading the Llama book the following day, I thought I did fairly well for a clueless newbie. ;)

    Frog

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://254490]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-03-28 16:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found