the 80 chars are specified in an RFC, but I can't remember which one

You can read it object by object, i.e. not \n as a input record separator, but \n\n....

my $LDIF; unless (open ($LDIF, "<", $ldifFile)) { die "Error in reading '$ldifFile': $!\n"; } else { local $/ = "\n\n"; # set input record separator to \n\n while (my $object = <$LDIF>) { chomp($object); $object =~ s/\n //g; # kill continuation lines print $object, "\n\n"; } # while close ($LDIF); } # else

well, the chomp and the print ... "\n\n" are not really necessary in this case

Or use Net::LDAP::LDIF for a better solution

or as a one-liner for windows:

perl -e "$/ = qq~\n\n~" -pe "s/\n /g" infile > outfile

or for unix/linux:

perl -e '$/ = "\n\n"' -pe 's/\n /g' infile > outfile

Best regards,
perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8.8.8.32.11.32"


In reply to Re: perl one-liner, is it possible? by strat
in thread perl one-liner, is it possible? by hxwu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.