What's the point of these lines of code?

G

grocery_stocker

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.
 
G

grocery_stocker

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.
 
I

Ian Wilson

grocery_stocker said:
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.
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top