From owner-freebsd-questions@FreeBSD.ORG Tue Nov 24 00:29:31 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 38D64106566C for ; Tue, 24 Nov 2009 00:29:31 +0000 (UTC) (envelope-from kline@thought.org) Received: from aristotle.thought.org (aristotle.thought.org [209.180.213.210]) by mx1.freebsd.org (Postfix) with ESMTP id CFDD38FC08 for ; Tue, 24 Nov 2009 00:29:29 +0000 (UTC) Received: from thought.org (tao.thought.org [10.47.0.250]) (authenticated bits=0) by aristotle.thought.org (8.14.2/8.14.2) with ESMTP id nAO0T6SU010091 for ; Mon, 23 Nov 2009 16:29:06 -0800 (PST) (envelope-from kline@thought.org) Received: by thought.org (nbSMTP-1.00) for uid 1002 kline@thought.org; Mon, 23 Nov 2009 16:29:23 -0800 (PST) Date: Mon, 23 Nov 2009 16:29:23 -0800 From: Gary Kline To: FreeBSD Mailing List Message-ID: <20091124002920.GA51110@thought.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2.3i X-Organization: Thought Unlimited. Public service Unix since 1986. X-Of_Interest: With 23 years of service to the Unix community. X-Spam-Status: No, score=-4.4 required=3.6 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.2.3 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on aristotle.thought.org Cc: Subject: 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: Tue, 24 Nov 2009 00:29:31 -0000 some several weeks ago, i got the appended perl code sent that takes a very long txt file and diving by ``Chapter NN'' puts the long file into seperate files, 01 to 66. trouble is that it is hard to read by eyes without a space between paragraphs. it's easy for grep to remove all newlines. How do i add them back? tia gary PS: having long, wrapped lines would work best ENCL: txt2chapts.pl #!/usr/bin/perl -w #) { chomp; if (/$regex/) { $fh = newchapter($1); print $fh "$preamble" . "$_"; last; } $preamble .= "$_" . "$/"; } # We've read at least one chapter heading. while (<>) { chomp; $fh = newchapter($1) if /$regex/; next if /^#/; print $fh "$_"; } close($fh); exit(0); # Open a new chapter if we match the regular expression. sub newchapter { my $n = shift || die "need a number"; my $file = sprintf("%2.2d", $n); close($fh) if defined($fh); open($fh, "> $file") or die "$file: $!\n"; return $fh; } /* FWIW: here are a few paragraphs from chapter one */ Chapter One "We're here," Erik said to his date as he swung his van into the diabled slot of the Blue Note Tavern's parking lot. For the slightest moment he was awkstruck at how pretty she was. That the girl was blind meant nothing to Erik. She could've been blind, deaf, and missing her right leg. The only thing he was certain of was that he wanted her--maybe worse that he'd wanted anything. *Ever.* The radio interrupted with the weather forecast just then. "It's cold out there, folks, so bundle up! It's 21 degrees here in Pine Falls, but the wind chill is a brisk minus 23 to around 40 degrees. Now the forecast for all of Northwest Wisconsin: From 10 to 20 degrees with dangerously cold wind chills ranging to minus 40 degrees. Less windy and much warmer tomorrow and even warmer on Sunday." "Typical November weather," he said, but no problem," he said. "We're right by the front door!" "You're in a wheelie spot?" she asked. "You bet!" Dawn said, "My brother Morgan says it's wrong to have this. He thinks it's reverse discrimination; that whoever gets to the nearest parking space first ought to get it. I tell him, God forbid he should ever be disabled!"