Solved

What does this perl code do? : perl -nle '/(\S+\.C)\W*$/ and print \$1'

Posted on 2011-09-30
2
372 Views
Last Modified: 2012-05-12
Can someone please explain verbosely what the following perl code does?

perl -nle '/(\S+\.C)\W*$/ and print \$1'
0
Comment
Question by:Phazz
2 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 36890446
It prints the scalar reference address of the first captured match whenever the standard input has a line containing nonblank characters followed by a dot, followed by a C, not followed by any word characers

It would make more sense without the \ in front of the $1
0
 

Author Comment

by:Phazz
ID: 36890471
Aha!

It is used for filtering the output from a g++ compliation of a C++ project, so that only lines ending on ".C" are output.

Thanks!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Merge files & delete row based on criteria using Perl. 1 106
Expect & sshpass package for Solaris 10 x86 15 996
instmodsh - listing perl modules 2 91
Perl modules on linux ec2 3 123
I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question