Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Pattern Matchingby fatfinger (Initiate) |
on Nov 19, 2008 at 13:15 UTC ( [id://724572]=perlquestion: print w/replies, xml ) | Need Help?? |
fatfinger has asked for the wisdom of the Perl Monks concerning the following question:
Hey Monks...I have a Perl question that deals with a huge text file. I currently have a script that opens a text file, prompts a user for input, and reads in the lines looking for the users input (pattern). When the script finds the users input or pattern, it extracts that line and prints it to an outfile. Pretty straight forward.
Question: My friend now wants to see more context not just the line where the term resides. Basically I need to find the text above and the text below the line that contains the user input? One other thing to mention ...this input file is blocks of text/sentences/phrases/embedded whitespaces, no real defined format. Might there be a way to manipulate the above script to do what I need to do or do I need to go a different direction all together? Any help or code samples you guys could provide would be great. Thanks Andrew
Back to
Seekers of Perl Wisdom
|
|