in reply to How to look for patterns in a file and create a CR

It's a bit hard to tell exactly what you want to do (please use <code> tags when you enter something that needs to retain its format), but here is a guess that might set you on your way. It slurps the entire file up at once (which may not work if it is really huge), then removes single newlines embedded in the pattern and adds a leading newline. Naturally you may want to generalize this to work for other patterns: perl -e "undef $/;$_=<>;s/G\n?5\n?7/\nG57/g;print;" yourfile.txt

Replies are listed 'Best First'.
Re: Re: How to look for patterns in a file and create a CR
by juo (Curate) on Mar 21, 2001 at 14:51 UTC
    When I submit a question and I perform a preview all the lines or standing after each other and my returns dissepeared. With adding <code> do you mean that every time I want a return I should add at the end of my line #<#CR> ? Pieter
      Put code tags like this:
      <code>
      use strict; my $var = 0; ...
      </code>
      around your code.
      Its in the Site How To

      --
      my $chainsaw = 'Perl';