Re: Typesetting (unwrap.pl)

michael said:
Let's have the code
sure thing, boss.
and install it where everyone can find/use it.
great idea...
Help Newby set it up later.
i don't think he will need any help, but yeah, sure. and, of course, i invite people to improve the script. -bowerbird =========================================== #!/usr/local/bin/perl -w use CGI::Carp qw(fatalsToBrowser); ########### read the user input read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); # Split the name-value pairs @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); # Un-Webify plus signs and %-encoding $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s/<!--(.|\n)*-->//g; if ($allow_html != 0) { $value =~ s/<([^>]|\n)*>//g; } $FORM{$name} = $value; $value =~ s/\cM//g; if ($name eq "theinput") {$thebook=$value}; } if ($thebook eq "") { $thebook='paste the text you want to unwrap in this field, and click "unwrap"...' }; print "content-type: text/html\n\n"; print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'; print "\n"; print "\n"; print '<head><title>unwrap p.g. paragraphs'; print '</title>'; print "\n"; print '<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">'; print '<body><pre>'; print '<form method="post"'; ######################################################### ### note that this line has to be changed to point to the appropriate place ### print 'action="http://z-m-l.com/go/unwrap.pl">'; ######################################################### print '<input align="left" type="submit" value="-- unwrap --"> '; print "\n"; print '<input type="hidden" name="unwrap" value="reporting...">'; print "\n"; print '<p align="left">'; print '<textarea name="theinput" rows=30 cols=80>'; print $thebook; print '</textarea>'; print '</p>'; print '<input type="hidden" name="hiddenname" value="hiddenvalue">'; ### the numbers here refer to a list of steps ### i posted in a message to gutvol-d ### #1 #skip #2 $thebook =~ s/\r\n/\n/g ; #3 $thebook =~ s/\r/\n/g ; #4 #skip #5 #skip #6 $thebook =~ s/ \n/\n/g ; $thebook =~ s/ \n/\n/g ; $thebook =~ s/ \n/\n/g ; $thebook =~ s/ \n/\n/g ; $thebook =~ s/ \n/\n/g ; $thebook =~ s/ \n/\n/g ; $thebook =~ s/ \n/\n/g ; $thebook =~ s/ \n/\n/g ; #7 $thebook =~ s/\n/ \n/g ; #8 $thebook =~ s/ \n \n/\n\n/g ; #9 $thebook =~ s/\n \n/\n\n/g ; $thebook =~ s/\n \n/\n\n/g ; $thebook =~ s/\n \n/\n\n/g ; $thebook =~ s/\n \n/\n\n/g ; #10 # wait! not yet! #11 $thebook =~ s/ \n /\n /g ; # maybe clone this for an asterisk in column 1, and # clone this for a number in column 1 which is # followed by a period-space in columns 2-3. $thebook =~ s/ \n>/\n>/g ; $thebook =~ s/ \n</\n</g ; $thebook =~ s/ \n\t/\n\t/g ; $thebook =~ s| \n/tab|\n/tab|g ; #12 $thebook =~ s/ \n/ /g ; print $thebook; print "</form></pre></body></html>";

Sorry, (not a perl programmer) perhaps you can provide some hints on how to get this to work. I tried it on my machine and this is what I got: C:\JIM\Perl>bbunwrap.pl < matra11.txt > matra11.html [Wed Apr 21 15:16:25 2010] bbunwrap.pl: Name "main::allow_html" used only once: possible typo at C:\JIM\Perl\bbunwrap.pl line 15. [Wed Apr 21 15:16:25 2010] bbunwrap.pl: Name "main::FORM" used only once: possib le typo at C:\JIM\Perl\bbunwrap.pl line 18. [Wed Apr 21 15:16:25 2010] bbunwrap.pl: Use of uninitialized value in read at C: \JIM\Perl\bbunwrap.pl line 5. [Wed Apr 21 15:16:25 2010] bbunwrap.pl: Use of uninitialized value $thebook in s tring eq at C:\JIM\Perl\bbunwrap.pl line 24.

http://pglaf.org/cgi-bin/unwrap.pl A few small changes: #!/usr/local/bin/perl -w use strict; # gbn use CGI::Carp qw(fatalsToBrowser); ########### read the user input my $buffer; my $thebook=""; # gbn read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); # Split the name-value pairs my @pairs = split(/&/, $buffer); foreach my $pair (@pairs) { (my $name, my $value) = split(/=/, $pair); # Un-Webify plus signs and %-encoding $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s/<!--(.|\n)*-->//g; # gbn: if ($allow_html != 0) { # $value =~ s/<([^>]|\n)*>//g; # } # gbn: $FORM{$name} = $value; $value =~ s/\cM//g; if ($name eq "theinput") {$thebook=$value}; } if ($thebook eq "") { $thebook='paste the text you want to unwrap in this field, and click "unwrap"...' }; print "content-type: text/html\n\n"; print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'; print "\n"; print "\n"; print '<head><title>unwrap p.g. paragraphs'; print '</title>'; print "\n"; print '<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">'; print '<body><pre>'; print '<form method="post"'; ######################################################### ### note that this line has to be changed to point to the appropriate ### place # gbn: print 'action="http://z-m-l.com/go/unwrap.pl">'; print 'action="http://pglaf.org/cgi-bin/unwrap.pl">'; ######################################################### print '<input align="left" type="submit" value="-- unwrap --"> '; print "\n"; print '<input type="hidden" name="unwrap" value="reporting...">'; print "\n"; print '<p align="left">'; print '<textarea name="theinput" rows=30 cols=80>'; print $thebook; print '</textarea>'; print '</p>'; print '<input type="hidden" name="hiddenname" value="hiddenvalue">'; ### the numbers here refer to a list of steps ### i posted in a message to gutvol-d ### #1 #skip #2 $thebook =~ s/\r\n/\n/g ; #3 $thebook =~ s/\r/\n/g ; #4 #skip #5 #skip #6 $thebook =~ s/ \n/\n/g ; $thebook =~ s/ \n/\n/g ; $thebook =~ s/ \n/\n/g ; $thebook =~ s/ \n/\n/g ; $thebook =~ s/ \n/\n/g ; $thebook =~ s/ \n/\n/g ; $thebook =~ s/ \n/\n/g ; $thebook =~ s/ \n/\n/g ; #7 $thebook =~ s/\n/ \n/g ; #8 $thebook =~ s/ \n \n/\n\n/g ; #9 $thebook =~ s/\n \n/\n\n/g ; $thebook =~ s/\n \n/\n\n/g ; $thebook =~ s/\n \n/\n\n/g ; $thebook =~ s/\n \n/\n\n/g ; #10 # wait! not yet! #11 $thebook =~ s/ \n /\n /g ; # maybe clone this for an asterisk in column 1, and # clone this for a number in column 1 which is # followed by a period-space in columns 2-3. $thebook =~ s/ \n>/\n>/g ; $thebook =~ s/ \n</\n</g ; $thebook =~ s/ \n\t/\n\t/g ; $thebook =~ s| \n/tab|\n/tab|g ; #12 $thebook =~ s/ \n/ /g ; print $thebook; print "</form></pre></body></html>"; On Wed, Apr 21, 2010 at 03:54:34PM -0400, Bowerbird@aol.com wrote:
michael said:
Let's have the code
sure thing, boss.
and install it where everyone can find/use it.
great idea...
Help Newby set it up later.
i don't think he will need any help, but yeah, sure.
and, of course, i invite people to improve the script.
-bowerbird
===========================================
#!/usr/local/bin/perl -w use CGI::Carp qw(fatalsToBrowser);
########### read the user input read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
# Split the name-value pairs @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); # Un-Webify plus signs and %-encoding $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s/<!--(.|\n)*-->//g; if ($allow_html != 0) { $value =~ s/<([^>]|\n)*>//g; } $FORM{$name} = $value; $value =~ s/\cM//g; if ($name eq "theinput") {$thebook=$value}; }
if ($thebook eq "") { $thebook='paste the text you want to unwrap in this field, and click "unwrap"...' };
print "content-type: text/html\n\n"; print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'; print "\n"; print "\n"; print '<head><title>unwrap p.g. paragraphs'; print '</title>'; print "\n"; print '<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">'; print '<body><pre>';
print '<form method="post"';
######################################################### ### note that this line has to be changed to point to the appropriate place ### print 'action="http://z-m-l.com/go/unwrap.pl">'; #########################################################
print '<input align="left" type="submit" value="-- unwrap --"> '; print "\n"; print '<input type="hidden" name="unwrap" value="reporting...">'; print "\n"; print '<p align="left">'; print '<textarea name="theinput" rows=30 cols=80>'; print $thebook; print '</textarea>'; print '</p>'; print '<input type="hidden" name="hiddenname" value="hiddenvalue">';
### the numbers here refer to a list of steps ### i posted in a message to gutvol-d ###
#1 #skip #2 $thebook =~ s/\r\n/\n/g ; #3 $thebook =~ s/\r/\n/g ; #4 #skip #5 #skip #6 $thebook =~ s/ \n/\n/g ; $thebook =~ s/ \n/\n/g ; $thebook =~ s/ \n/\n/g ; $thebook =~ s/ \n/\n/g ; $thebook =~ s/ \n/\n/g ; $thebook =~ s/ \n/\n/g ; $thebook =~ s/ \n/\n/g ; $thebook =~ s/ \n/\n/g ; #7 $thebook =~ s/\n/ \n/g ; #8 $thebook =~ s/ \n \n/\n\n/g ; #9 $thebook =~ s/\n \n/\n\n/g ; $thebook =~ s/\n \n/\n\n/g ; $thebook =~ s/\n \n/\n\n/g ; $thebook =~ s/\n \n/\n\n/g ; #10 # wait! not yet! #11 $thebook =~ s/ \n /\n /g ; # maybe clone this for an asterisk in column 1, and # clone this for a number in column 1 which is # followed by a period-space in columns 2-3. $thebook =~ s/ \n>/\n>/g ; $thebook =~ s/ \n</\n</g ; $thebook =~ s/ \n\t/\n\t/g ; $thebook =~ s| \n/tab|\n/tab|g ; #12 $thebook =~ s/ \n/ /g ;
print $thebook;
print "</form></pre></body></html>";
_______________________________________________ gutvol-d mailing list gutvol-d@lists.pglaf.org http://lists.pglaf.org/mailman/listinfo/gutvol-d

A few small changes:
Sorry, I'm not too sure how you are doing it, but it shows up "unwrapped" as html in the web browser, but if I actually try to save it as a text file, either by cut-and-paste or by File Save = name.txt then the text magically shows up wrapped again. I think what people want is an unwrapped txt file that they can actually save and can read in their choice of txt reader or txt editor.
participants (3)
-
Bowerbird@aol.com
-
Greg Newby
-
James Adcock