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
In reply to Re: Adding back missing newlines between records
by ikegami
in thread Adding back missing newlines between records
by puterboy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |