Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Just Another Net::FTP Script

by grinder (Bishop)
on Jun 20, 2001 at 15:35 UTC ( [id://90041]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to (code) Just Another Net::FTP Script

A minor quibble with the way you generate timestamps (in the LocalTime subroutine).

  • I don't like little subroutines that call print themselves. I prefer to return a string, and have the parent code call print. This lets you fold the call into a list of other things that are also passed to print. One of these days you'll want to fetch what LocalTime produces, but not have it print out anything. At that point you will be forced to either clone the code into a separate routine (and if you're smart you'll refactor the current routine in terms of that new routine), or else you'll have to pass an ugly mode param that tells the code whether it should print out or just return the string.
  • Use the ISO date format.
  • Call localtime once.

Putting it all together, you get something like:

sub timestamp { sprintf '%4d-%02d-%02d:%02d:%02d:%02d', sub{ $_[5]+1900, $_[4]+1, @_[reverse 0..3] }->(localtime) }

Note that this string is not perfect as it does not encode the local time zone. That, of course, is left as an exercise to the reader.


--
g r i n d e r

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://90041]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.