Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Logging Version and Date-Time

by hsmyers (Canon)
on Mar 07, 2011 at 21:24 UTC ( #891912=CUFP: print w/replies, xml ) Need Help??

This may be trivial, but it is handy when you have to mark the version of a script running on various output, particularly when there are a number of processes and a great deal of data--- providing the thicket to get lost in!
#!/usr/bin/perl # -- use strict; use warnings; use diagnostics; use feature ":5.10"; use autodie; use version 0.77; use Data::Dumper::Simple; our $VERSION = '0.042'; # # variations on a theme as needed (not by Thomis Talis) # #sign_on(); #sign_on(*STDOUT); #my $fh; #open($fh,'>','ttime.log'); #sign_on($fh); # # NOTE: this will leave the program extension on to differentiate # between running under cygwin/unix where I typically strip off the # extension (cuts down on typing) as compared to a dos box where I # don't have to type the extension and therefore leave it alone... # sign_on(); sub sign_on { my $out = @_ ? shift : *STDERR; my $date = localtime(); (my $program = $0) =~ (s/.*(?:\/|\\)(.*?..*$)/$1/); my $version = version->parse($VERSION); print $out "$program v$version, $date\n"; }
Ignore the stupid program title and the use Data::Dumper::Simple; it is part of my template based boiler plate...


"Never try to teach a pig to wastes your time and it annoys the pig."

Replies are listed 'Best First'.
Re: Logging Version and Date-Time
by Anonymous Monk on Mar 07, 2011 at 21:44 UTC
      Color me confused (not hard to do...) If your criticism was about the use of the under-bar in the sub routine name then the links to tye's material would seem to partially argue against such a pseudo prohibition. If it wasn't, then I'm completely out to sea here. Although I will admit that I find all of the material interesting.


      "Never try to teach a pig to wastes your time and it annoys the pig."

        My guess was that it was a pointer to an alternative / additional template / "boiler plate". But I found it confusing as well.

        - tye        

        Although I will admit that I find all of the material interesting

        Sorry, "see also" was the point

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: CUFP [id://891912]
Approved by ww
Front-paged by Arunbear
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2023-12-11 22:44 GMT
Find Nodes?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?

    Results (41 votes). Check out past polls.