Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I have a novice question concerning the extraction of information from a large text file.
I want to look up a line that starts with '0010 0010', and extract the text on the same line that comes after the second double forward slash and before the end of the line, and assign this to a string.
For example, if a line contains:
0010 0010 (text) // (text) // JOHN DOE
I would like to end up with a string that has the value "JOHN DOE"
This command seems to perform the extraction correctly from the command line:
perl -lne 'print if s/0010 0010.*\/\/.*\/\///'
but I can't figure out a way of doing this from within a script, which is what I need.
I have tried various pattern matching things such as $name=~s/^(pattern)$//mgi, but nothing seems to work.
The solution is probably pretty obvious to anyone with a little experience, but I have none.
Thanks in advance
S
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: pattern matching
by Corion (Patriarch) on May 04, 2004 at 10:59 UTC | |
by perlcgi (Hermit) on May 04, 2004 at 13:59 UTC | |
|
Re: pattern matching
by perlinux (Deacon) on May 04, 2004 at 11:36 UTC | |
by Anomynous Monk (Scribe) on May 04, 2004 at 18:18 UTC | |
|
Re: pattern matching
by delirium (Chaplain) on May 04, 2004 at 12:33 UTC |