Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

extracting a certain field from a file

Posted on 2003-03-04
1
Medium Priority
?
192 Views
Last Modified: 2010-03-05
Hi
I am new to perl and I would like to know How can I do the following in perl
-scan an input file line by line
- look for a keyword and extract the number(float) that comes after the key word.

Please help.
Thank you

P.S. I know how to scan an input file line by line, but I am confused about how to do the testing and number extraction.
 
0
Comment
Question by:NK66
1 Comment
 
LVL 85

Accepted Solution

by:
ozo earned 150 total points
ID: 8069924
#!/usr/bin/perl
while( <> ){
    print "$1\n" if /keyword\s+(\S+)/;
}
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

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

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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…
Six Sigma Control Plans
Suggested Courses

564 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