in reply to Adding back missing newlines between records
My problem is that somehow I can't seem to search across the newline which is what I thought the /s was supposed to help with
The s modifier makes . match every character, including the newline which it doesn't match by default. Useless here since you don't use ..
The -p causes the expression to be applies to each line of input. You're trying to match something you haven't read yet! One way of fixing this is to change the definition of line so that the whole file is read at once. (-0777)
Then there's the issue that /(?=\w)\n/ will never match. How can the next character be both a word character and a newline?
perl -0777pe's/(?<!\n)\n# file/\n\n# file/g' record_file
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Adding back missing newlines between records
by 7stud (Deacon) on Nov 06, 2009 at 11:08 UTC | |
by johngg (Canon) on Nov 06, 2009 at 11:29 UTC | |
by Anonymous Monk on Nov 06, 2009 at 11:27 UTC | |
by 7stud (Deacon) on Nov 06, 2009 at 12:20 UTC | |
by 7stud (Deacon) on Nov 06, 2009 at 12:38 UTC | |
by Anonymous Monk on Nov 06, 2009 at 12:42 UTC | |
by 7stud (Deacon) on Nov 06, 2009 at 12:06 UTC | |
|
Re^2: Adding back missing newlines between records
by puterboy (Scribe) on Nov 10, 2009 at 07:21 UTC |