How are you going to tell when a file was produced? Which script (and which version of it) produced the output? What system was used to compute the result?
#!/usr/local/bin/perl -w
#
# stamp_output.pl - demo script for CBMG688P
#
use strict;
my $version = '$Id$';
my $date = '';
my $system = '';
print "# version = $version\n# date = $date\n# system = $system\n";
exit(0);
When we changed version to $Id$, then committed this to CVS, we got a version stamp on our file. Here's the version string for this html file:
$Id: stamp_output_lesson.html,v 1.4 2010/12/20 15:54:25 arlin Exp $
That has a date on it, but its not now-- it's the date this file was checked in last. How do we get the present time, i.e., now?
unix_prompt$ date
And how can we get some information on our system? Like this:
unix_prompt$ uname -a
So, now we have everything we need to know except for one thing. How do we run a system command from within a Perl script? One way is with system( "command" ), but the one we want is `date`. The back-ticks are important. Without them, it won't work. Try it:
unix_prompt$ perl -e 'print date'
unix_prompt$ perl -e 'print "date"'
unix_prompt$ perl -e 'print `date`'
So, I will leave it to you to incorporate date and uname -a into the script.
Once that is done, let us check it in again using CVS.
What if you want to record all of the command-line options? Can someone figure that out?