From: J. Gleixner on
Newsgroup Reader wrote:
> Hi Paul:
>
> The source code control repository puts in this version number as a
> comment, so I cannot use the variable. The code looks like:
>
> # $Revision: 1.9 $

Give this a try:

use vars qw( $VERSION );
( $VERSION ) = '$Revision:$ ' =~ /\$Revision:\s+([^\s]+)/;

Then, after you commit the version, $VERSION will be set to the Revision
from CVS. If you're using some other revision control, there should be
something similar.
From: Newsgroup Reader on
Thanks, I'll try this. The source code control system being used in
this system is PVCS. I can read the version if I re-open the script as
a text file. Still have to try the DATA filehandle approach so I won't
have to re-open the file.

From: Darren Dunham on
Newsgroup Reader <ng.reader(a)gmail.com> wrote:
> Hi Paul:

> The source code control repository puts in this version number as a
> comment

Whether it's truly a perl comment or not depends on the surrounding
lines.

> , so I cannot use the variable. The code looks like:

> # $Revision: 1.9 $

Is it located somewhere in particular in the file? I assume it's not
simply the first line. If you can code ahead of it, how about something
like this?

my $version = q(
# $Revision: 1.9 $
);

$version =~ s/^.*Revision\:\s*([\d.]+)\s.*$/$1/s;

print "My version is $version.\n";

--
Darren Dunham ddunham(a)taos.com
Senior Technical Consultant TAOS http://www.taos.com/
Got some Dr Pepper? San Francisco, CA bay area
< This line left intentionally blank to confuse you. >
From: Chris Richmond - MD6-FDC ~ on
Here's an alternate that works for us:

$::VersionString = q|$Id: asm2trc.pl,v 1.24 2005/11/28 22:37:03 crichmon Exp $|;

print "\n$::VersionString\n\n";

Same trick works with any of the other rcs/cvs variables.

Chris
--
Chris Richmond | I don't speak for Intel & vise versa

First  |  Prev  | 
Pages: 1 2 3
Prev: Perl Integer Length
Next: FTP PUT with proxy?