puterboy has asked for the wisdom of the Perl Monks concerning the following question:
I have a set of records in plaintext where each record begins with "# file" and that line doesn't appear anywhere but the start of the record. Records should be separated by a blank line (\n\n) but some records are missing the space.
I thought the following perl one-liner would work but it doesn't. What am I doing wrong???
cat <record file> | perl -p -e "s/(?=\w)\n# file/\n\n# file/sg"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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Adding back missing newlines between records
by ikegami (Patriarch) on Nov 06, 2009 at 06:30 UTC | |
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:38 UTC | |
by Anonymous Monk on Nov 06, 2009 at 12:42 UTC | |
by 7stud (Deacon) on Nov 06, 2009 at 12:20 UTC | |
by 7stud (Deacon) on Nov 06, 2009 at 12:06 UTC | |
by puterboy (Scribe) on Nov 10, 2009 at 07:21 UTC |
Back to
Seekers of Perl Wisdom