nvdierdo has asked for the wisdom of the Perl Monks concerning the following question:
I want to match 2 strings on different lines in a file. The strings are not on the same line. New lines are coded as a <cr><lf> pair (windows).
My text file is myfile.txt:
..some random text..name="Bob"..some more random text containing new lines..
..some random text..id="437"..yet some more text
I tried the following which didn't work:
perl -ne "print \"$1\n$2\n\" while /name=\"(.*)\".*id=\"(.*)\"/gs" myfile.txtWhat is wrong with this?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: how to deal with newline
by Corion (Patriarch) on Oct 27, 2013 at 15:27 UTC | |
|
Re: how to deal with newline
by NetWallah (Canon) on Oct 27, 2013 at 16:38 UTC | |
|
Re: how to deal with newline
by Laurent_R (Canon) on Oct 27, 2013 at 16:55 UTC | |
|
Re: how to deal with newline
by Lennotoecom (Pilgrim) on Oct 27, 2013 at 20:02 UTC |