in reply to Re: replace \n with space to join indented lines
in thread replace \n with space to join indented lines

Thank you very much jwkrahn. Your code works a treat. However, I do not understand it. Would you mind explaining it step by step please? Thank you olivier
  • Comment on Re^2: replace \n with space to join indented lines

Replies are listed 'Best First'.
Re^3: replace \n with space to join indented lines
by jwkrahn (Abbot) on Dec 05, 2006 at 15:37 UTC
    perl -lpe'
    Setup a while loop that automatically prints the current line and with the -l switch chomps the input and appends the output record separator.
    BEGIN { $/ = "\n " }
    Change the input record separator to a newline followed by four spaces.
    $\ = y/\n// ? $/ : $"'
    With the chomped line (after the input record separator has been removed), count the number of newlines. If there are no newlines then set the output record separator to the list separator (a single space), otherwise set the output record separator to the input record separator.

      That's great. Thank you very much indeed.