The stupid question is the question not asked | |
PerlMonks |
pattern matchingby Anonymous Monk |
on May 04, 2004 at 10:47 UTC ( [id://350284]=perlquestion: print w/replies, xml ) | Need Help?? |
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Peace be unto you, O enlightened ones 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. Thanks in advance S
Back to
Seekers of Perl Wisdom
|
|