Hey Chas,

Thanks, I run Win2k so had to make some changes (the unix \r\n is just
\n on the M$ OS's).  I also had a question.

{
   You wrapped some of your code in curlies like this paragraph, and I
   don't understand why... Seems to work fine without.
}

Also, I had not thought of converting to Palm DOC format using perl
(silly me, it would save a mousing set of steps).  I use QEX - a
companion to QED (that lets you edit DOC's on the Palm).  If anyone
knows of a Perl module to do this, I would love to hear about it (or
any module that works with the Palm database files on M$ - the one I
am aware of only works with the Palm db's on UNIX).

Was asked to post the code when I had it working as I wanted, so here
it is (without the conversion to Palm DOC though).

<code>
#!/usr/bin/perl -w
use strict;
use diagnostics;

open(OUTfile, ">$ARGV[0].2palm"); # file to write to

    #Project Gutenberg eText seem to have a line like:
#*END*THE SMALL print OUTfile! FOR PUBLIC DOMAIN ETEXTS*Ver.04.29.93*END*\n
    #at the end of the header, so read everthing in until first *END*\n
local($/) = "*END*\n"; # set the input separator
my $header = <>; # read in until $/

local($/) = "Chapter"; # set the input separator to retain CONTENTS formating
my $Chapter = <>; # read in more (till $/ again) ending at first "Chapter"
print OUTfile "\n$Chapter"; # print OUTfile the CONTENTS

local($/) = "\n\n"; # set line seperator to a blank line
while (<>) { # read in all paragraphs
    s/\n/ /g; # remove all new lines in paragraph
    print OUTfile "$_\n\n"; # print OUTfile paragraph with a blank line after it
}

print OUTfile "\n\n$header"; # print OUTfile header
</code>

Friday, June 15, 2001, 5:28:49 PM, you wrote:

CO> On 15 Jun 2001 16:04:55 -0400, Tim Musson wrote:
>> Hey Perlers,
>> 
>>   I have pulled some books from Project Gutenberg (www.Gutenberg.net).
>>   What I want to do is take all the Paragraphs and put them on one
>>   line, then put them into the Palm DOC format.  This way they wrap
>>   correctly on the Palm screen.
>> 
>>   There is no indenting that I care about, so I would say that I could
>>   take any block of text and put it all on one line.  Starting a new
>>   block after each blank line.
>> 
>>   I would also like to take the PG headders (disclaimers, how to
>>   donate, etc.) and move it to the bottom of the text, so a way to do
>>   that would be cool too!
>> 
>>   Any suggestions would be appreciated.
>> 
>>   Thanks, you all are great!
CO> <snip />

CO> I tested this against several ebooks downloaded from Project Gutenberg
CO> and it seems to work like you want except for converting to Palm DOC.  I
CO> will post an update when I find documentation for the format.  

CO> <code>
CO> #!/usr/bin/perl -w

CO> use strict;

CO> my $header; #hold the header until the end

CO> {
CO>         #ebooks seems to have a line like:
CO> #*END*THE SMALL PRINT! FOR PUBLIC DOMAIN ETEXTS*Ver.04.29.93*END*\r\n
CO>         #at the end of the header, so read everthing in until 
CO>         #first *END*\r\n
CO>         local($/) = "*END*\r\n"; 

CO>         $header = <>;

CO> }

CO> {
CO>         #set line seperator to a blank line
CO>         local($/) = "\r\n\r\n";
        
CO>         #read in all paragraphs
CO>         while (<>) {
CO>                 #remove all <CR><LF> pairs in paragraph 
CO>                 s/\r\n/ /g;
CO>                 #print paragraph with a blank line after it
CO>                 print "$_\r\n\r\n";
CO>         }
CO> }

CO> #print header
CO> print "$header";
CO> </code>

CO> --
CO> Today is Sweetmorn, the 20th day of Confusion in the YOLD 3167
CO> Keep the Lasagna flying!





-- 
[EMAIL PROTECTED]
Using The Bat! eMail v1.53
Windows NT 5.0.2195 (Service Pack 1)
The generation of random numbers is too important to be left to chance.


NetZero Platinum
No Banner Ads and Unlimited Access
Sign Up Today - Only $9.95 per month!
http://www.netzero.net

Reply via email to