From owner-freebsd-questions@FreeBSD.ORG Wed Nov 25 20:36:44 2009 Return-Path: Delivered-To: freebsd-questions@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 25D321065672 for ; Wed, 25 Nov 2009 20:36:44 +0000 (UTC) (envelope-from perrin@apotheon.com) Received: from outbound-mail-129.bluehost.com (outbound-mail-129.bluehost.com [67.222.38.29]) by mx1.freebsd.org (Postfix) with SMTP id EB9378FC08 for ; Wed, 25 Nov 2009 20:36:43 +0000 (UTC) Received: (qmail 9930 invoked by uid 0); 25 Nov 2009 20:36:43 -0000 Received: from unknown (HELO box543.bluehost.com) (74.220.219.143) by outboundproxy4.bluehost.com with SMTP; 25 Nov 2009 20:36:43 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=apotheon.com; h=Date:From:To:Cc:Subject:Message-ID:Mail-Followup-To:References:Mime-Version:Content-Type:Content-Disposition:In-Reply-To:User-Agent:X-Identified-User; b=m722LHP1nOM7D0UFGP0H+cq3Cswl3ORk0XM098NlELUoA/JCb3XoEBLvRJAJlDHNqqdrf6xSwEutKFj50hKoBdDyN/5+jmjIYYhrr8kDfvx2lT5N8BACMPn8JLvKSAnG; Received: from c-24-8-180-234.hsd1.co.comcast.net ([24.8.180.234] helo=kukaburra.hydra) by box543.bluehost.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1NDOGo-0001vn-62; Wed, 25 Nov 2009 13:15:22 -0700 Received: by kukaburra.hydra (sSMTP sendmail emulation); Wed, 25 Nov 2009 13:08:39 -0700 Date: Wed, 25 Nov 2009 13:08:39 -0700 From: Chad Perrin To: Gary Kline Message-ID: <20091125200839.GA4487@guilt.hydra> Mail-Followup-To: Gary Kline , FreeBSD Mailing List References: <20091124002920.GA51110@thought.org> <20091124003652.GH11723@hal.rescomp.berkeley.edu> <20091124013934.GA51279@thought.org> <20091124200741.GA1799@guilt.hydra> <20091124211942.GF54631@thought.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="r5Pyd7+fXNt84Ff3" Content-Disposition: inline In-Reply-To: <20091124211942.GF54631@thought.org> User-Agent: Mutt/1.4.2.3i X-Identified-User: {2737:box543.bluehost.com:apotheon:apotheon.org} {sentby:smtp auth 24.8.180.234 authed with ren@apotheon.org} Cc: FreeBSD Mailing List Subject: Re: need a newline between paragraphs.... X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Nov 2009 20:36:44 -0000 --r5Pyd7+fXNt84Ff3 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Nov 24, 2009 at 01:19:42PM -0800, Gary Kline wrote: > On Tue, Nov 24, 2009 at 01:07:41PM -0700, Chad Perrin wrote: >=20 > precisely. in this case, every paragraph that is not on a > newline wraps. so anything that has an EOL is a new > paragraph. If I understand you correctly, the following should work for your purposes (as a naive implementation of the concept): my $contents; { undef $/; open(my $fh, '<', $in_filename) or die $!; $contents =3D <$fh>; } $contents =3D~ s/\n+/\n\n/g; { open(my $fh, '>', $out_filename) or die $!; print($fh $contents); } That assumes that you want to turn any and all instances of one or more consecutive newlines into exacty two newlines. More finagling might be required if there may be other adjacent whitespace, which would need to account for not only possible adjacent whitespace but also possible whitespace at the beginning of a line with other text on it. Maybe something like this: $contents =3D~ s/\s*\n+/\n\n/g; =2E . . though I haven't thought it through in too much depth with regards to the implications in edge case circumstances (thus the "naive implementation" comment above). >=20 > there are a few places that require different formatting;=20 > these are easily re-done thanks to OOo! I'm the kind of guy who would look for a way to automate things so that re-formatting in OOo wouldn't be necessary, but as long as you're happy, I guess we win. Good luck! --=20 Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ] --r5Pyd7+fXNt84Ff3 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.13 (FreeBSD) iEYEARECAAYFAksNjscACgkQ9mn/Pj01uKV7XwCfbJqyZ5H+tvsxcUj9ah+e2+bB vTkAn0i3aVtyRwY3xUNnRtTvW4QiGMw5 =zMsO -----END PGP SIGNATURE----- --r5Pyd7+fXNt84Ff3--