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!
Ignore the stupid program title and the use Data::Dumper::Simple; it is part of my template based boiler plate...#!/usr/bin/perl # ttime.pl -- 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"; }
--hsm
"Never try to teach a pig to sing...it 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 | |
by hsmyers (Canon) on Mar 09, 2011 at 16:56 UTC | |
by tye (Sage) on Mar 09, 2011 at 19:02 UTC | |
by Anonymous Monk on Mar 09, 2011 at 19:29 UTC |
Back to
Cool Uses for Perl