What's the point of these lines of code?

Discussion in 'Perl Misc' started by grocery_stocker, May 23, 2007.

  1. This person has like 20 perl scripts related to Audio/Video streaming
    his stuff on the web. Just about every script has this near the top of
    it

    my $progname = $0; $progname =~ s@.*/@@g;
    my $version = q{ $Revision: 1.27 $ }; $version =~ s/^[^0-9]+([0-9.]+).*
    $/$1/;

    I thought he might be parsing some kind of RCS file to get the current
    version, but then that would explain

    my $version = q{ $Revision: 1.27 $ };

    Can someone clarify this for me please.
     
    grocery_stocker, May 23, 2007
    #1
    1. Advertising

  2. On May 22, 6:13 pm, grocery_stocker <> wrote:
    > This person has like 20 perl scripts related to Audio/Video streaming
    > his stuff on the web. Just about every script has this near the top of
    > it
    >
    > my $progname = $0; $progname =~ s@.*/@@g;
    > my $version = q{ $Revision: 1.27 $ }; $version =~ s/^[^0-9]+([0-9.]+).*
    > $/$1/;
    >
    > I thought he might be parsing some kind of RCS file to get the current
    > version, but then that would explain
    >
    > my $version = q{ $Revision: 1.27 $ };
    >
    > Can someone clarify this for me please.



    Never mind. I found my answers via Google.
     
    grocery_stocker, May 23, 2007
    #2
    1. Advertising

  3. grocery_stocker

    Ian Wilson Guest

    grocery_stocker wrote:
    > On May 22, 6:13 pm, grocery_stocker <> wrote:
    >
    >>This person has like 20 perl scripts related to Audio/Video streaming
    >>his stuff on the web. Just about every script has this near the top of
    >>it
    >>
    >>my $progname = $0; $progname =~ s@.*/@@g;
    >>my $version = q{ $Revision: 1.27 $ }; $version =~ s/^[^0-9]+([0-9.]+).*
    >>$/$1/;
    >>
    >>I thought he might be parsing some kind of RCS file to get the current
    >>version, but then that would explain
    >>
    >>my $version = q{ $Revision: 1.27 $ };
    >>
    >>Can someone clarify this for me please.

    >
    >
    >
    > Never mind. I found my answers via Google.
    >


    Maybe you'd like to post the answers here so that anyone else with a
    similar problem who finds this thread isn't frustrated by the omission
    of the answers they seek.

    My guesses:

    1) `my $progname = $0; $progname =~ s@.*/@@g;`
    removes the path from the program name

    2) `my $version = q{ $Revision: 1.27 $ };`
    allows the program to know and report its version, where the version
    number is maintained by checking changes to the file into the Revision
    Control System (RCS). RCS looks for and edits strings like "...
    $Revision: n.nn $ ..." which are usually placed in comments but can be
    placed in code statements if care is taken with the metacharacters.

    3) `$version =~ s/^[^0-9]+([0-9.]+).*$/$1/;`
    strips out the word "Revision:" and the major part of the version
    number. RCS never increments the major number unless the developer
    explicitly sets it.
     
    Ian Wilson, May 23, 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. Bryan
    Replies:
    1
    Views:
    323
    Harald Armin Massa
    May 9, 2006
  2. Replies:
    13
    Views:
    634
    Chris Smith
    Aug 16, 2007
  3. maheshkumar0459
    Replies:
    0
    Views:
    861
    maheshkumar0459
    Jul 6, 2011
  4. Saraswati lakki
    Replies:
    0
    Views:
    1,341
    Saraswati lakki
    Jan 6, 2012
  5. MohsinHijazee

    What these lines of code do?

    MohsinHijazee, Jan 23, 2008, in forum: Ruby
    Replies:
    7
    Views:
    100
    yermej
    Jan 24, 2008
Loading...

Share This Page