Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Can we assume that <nth line> really is just your notation for the beginning of a new line, where lines end with "\n"?
If that's the case:
Go ahead and give that a try. One problem your regexp has is that you're not putting a quantifier after your \w metachars. That means that you're trying to match a single word character, followed by any positive amount of whitespace, followed by a single word character, followed by a single whitespace, followed by any amount of anything. You really want to be matching words of arbitrary length, presumably longer than a single character each. Another problem your script has is that you're not checking for success when you open the file. You should probably be invoking die if there is a failure to open the file. See the example I provided. You can read up on this issue in perlopentut.
Dave In reply to Re: first two words-pattern matching
by davido
|
|