How can I write a Perl script that would scrape out sentences that mention 'Calvein Klein' in articles in a file named by $file
? (Sentences can cross zero or more CR/LF characters.) I want to create an array of sentences scraped and print it at the end.
This is as much fish as I'm going to give out today.
Clearly you need to:
- open the file
- read in its contents
- search through its lines for a particular pattern
- create an array of sentences that match
Now, as you set about implementing each of these steps, you may run into more issues, but I'm sure if you think about it carefully you'll be able to come up with the right questions to ask. Then you should search the SO archives before asking that question, as you're not asking anything particularly unique or that hasn't come up here several times before.
精彩评论