Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > What's the point of these lines of code?

Reply
Thread Tools

What's the point of these lines of code?

 
 
grocery_stocker
Guest
Posts: n/a
 
      05-23-2007
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.

 
Reply With Quote
 
 
 
 
grocery_stocker
Guest
Posts: n/a
 
      05-23-2007
On May 22, 6:13 pm, grocery_stocker <(E-Mail Removed)> 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.

 
Reply With Quote
 
 
 
 
Ian Wilson
Guest
Posts: n/a
 
      05-23-2007
grocery_stocker wrote:
> On May 22, 6:13 pm, grocery_stocker <(E-Mail Removed)> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Share-Point-2010 ,Share-Point -2010 Training , Share-point-2010Hyderabad , Share-point-2010 Institute Saraswati lakki ASP .Net 0 01-06-2012 06:39 AM
Scenario 5: IS-IS routing on Frame Relay Multi-point and Point-to-Point David Sudjiman Cisco 0 06-08-2006 09:11 AM
Java equivalent to these 5 lines of Perl Page Java 1 09-09-2004 03:25 PM
does these lines achive what I think: Didier Cisco 2 01-23-2004 02:17 PM
Can these two lines be optimized (JDOM,XSLT) ? Collin VanDyck Java 3 10-27-2003 01:52 PM



Advertisments