Version for Script?

T

T

Greetings:

At the beginning of all my Perl scripts I do:

#!/usr/local/bin/perl -w
# $Id$

The $Id$ will expand out in RCS/CVS to a version. My question is there
a way for me to get this in perl? It's in a comment line so will be
ignore by perl, but wondering if there's another way around this or
should I just create a $version variable and control the version that
way?

Thanks for any help in advance!

T
 
I

Ian Wilson

T said:
Greetings:

At the beginning of all my Perl scripts I do:

#!/usr/local/bin/perl -w
# $Id$

The $Id$ will expand out in RCS/CVS to a version. My question is there
a way for me to get this in perl? It's in a comment line so will be
ignore by perl, but wondering if there's another way around this or
should I just create a $version variable and control the version that
way?

Thanks for any help in advance!

T

#!perl
#
# $Author$
# $Date$
# $Header$
# $Id$
# $Locker$
# $Log$
# $Name$
# $Revision$
# $Source$
# $State$
#
use strict;
use warnings;
my $identifier = '$Id$';
print "Id : $identifier\n";
my $Revision = ''; // keep interpolater happy
my $nothing = ''; // ditto
print "Revision $Revision$nothing\n";

RCS/CVS don't care if the $Id$ is not in a comment, and will update all
occurrences of such keyword strings wherever they appear.
 
J

J. Gleixner

Ian said:
T said:
Greetings:

At the beginning of all my Perl scripts I do:

#!/usr/local/bin/perl -w
# $Id$

The $Id$ will expand out in RCS/CVS to a version. My question is there
a way for me to get this in perl? [...]
my $identifier = '$Id$';
print "Id : $identifier\n";
my $Revision = ''; // keep interpolater happy
my $nothing = ''; // ditto
print "Revision $Revision$nothing\n";

RCS/CVS don't care if the $Id$ is not in a comment, and will update all
occurrences of such keyword strings wherever they appear.

Or a little nicer, set your $VERSION to the Revision used by CVS.

# $Revision: $
use vars qw($VERSION);
$VERSION = sprintf "%d.%03d", q$Revision: $ =~ /(\d+)/g;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top