Version for Script?

Discussion in 'Perl Misc' started by T, Jul 27, 2007.

  1. T

    T Guest

    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
     
    T, Jul 27, 2007
    #1
    1. Advertising

  2. T

    Ian Wilson Guest

    T wrote:
    > 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.
     
    Ian Wilson, Jul 27, 2007
    #2
    1. Advertising

  3. T

    J. Gleixner Guest

    Ian Wilson wrote:
    > T wrote:
    >> 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;
     
    J. Gleixner, Jul 27, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. V Green
    Replies:
    0
    Views:
    865
    V Green
    Feb 5, 2008
  2. PA Bear [MS MVP]
    Replies:
    0
    Views:
    975
    PA Bear [MS MVP]
    Feb 5, 2008
  3. MowGreen [MVP]
    Replies:
    5
    Views:
    2,025
    PA Bear [MS MVP]
    Feb 9, 2008
  4. Rajat
    Replies:
    3
    Views:
    706
    Jorgen Grahn
    Jan 8, 2010
  5. VYAS ASHISH M-NTB837
    Replies:
    2
    Views:
    566
    Jan Kaliszewski
    Jan 7, 2010
Loading...

Share This Page