OK - here's an update on something I did that seems to work.
I open the file, and stuff it into an array:
open (FILE,"<$script_path/$file") || die "NFG1 $script_path/$file!\n";
@CONTENT = <FILE>;
close(FILE);
But instead of:
$Text::Wrap::columns = '40';
print wrap("","",@CONTENT);
I used a loop:
$Text::Wrap::columns = '40';
foreach (@CONTENT) {
print wrap("","",$_);
}
and all is working as expected. I'm just wondering if this is a case of treating the symptom, rather then the cause ...
Thanks for all who contributed ... at least I've got something working now.
| [reply] [d/l] [select] |
Google found this bug report in June 2000 with a similar problem. Maybe version 2001.0131 fixed it. poj
| [reply] |
Like sauoq, I have tried but failed to reproduce the results
you reported -- either of them -- using the four paragraphs
you cited. I am assuming that given this text, @CONTENT
should have 7 elements (maybe 8, at most 9, if you have
blank lines at the beginning and/or end of the array):
1: "This program ... details.\n"
2: "\n"
3: "You should have ... provide one.\n"
4: "\n"
5: "You should also ... /gpl.html.\n"
6: "\n"
7: "For those ... to use that.\n"
(update: added "\n" at the end of each
text line, just to be clear about that; also fixed the
summary of output below.)
Given data like that, and using these lines of code:
$Text::Wrap::columns = '40';
print wrap( '','',@CONTENT );
I get the following sequence of paragraphs (summarized):
This program is distributed in the hope
... ## 5 lines ## ...
Artistic License for more details.
You should have received a copy of the
... ## 2 lines ## ...
glad to provide one.
You should also have received a copy of
... ## 6 lines ## ...
on the internet at
http://www.gnu.org/copyleft/hhhhhhhhhhh
hh/hhhhhhhhhhhhhhhhhh/gpl.html.
For those of you that choose to use the
... ## 37 lines ## ...
protection, so you may prefer to use
that.
So it looks like the URL is being rendered where it should be.
Also, when I pipe the output through "od -a", I see that
the paragraph boundaries (the blank lines) are rendered
as two consecutive "nl" (\n) characters, with no extra
spaces. (But frankly, if there were extra spaces, I don't
know why this would be a problem.)
The only thing I would consider fixing is to have the
URL be broken after a slash character, rather than in the
middle of a "word" token, but that probably doesn't matter.
My Perl installation is v5.8.0 built for i686-linux,
and I'm using the "2001.0929" version of Text::Wrap.
What are you using, and how, exactly, are you filling the
@CONTENT array?
| [reply] [d/l] [select] |
First, thanks for you efforts ... this really is puzzling.
OK - I fooled around, and found an approach that eliminates the spaces, but not the "over the limit" word.
FWIW, I'm using Perl 5.00503 (OS solaris), and don't know the Text::Wrap version (I've no root access, but could find out the version if it ends up being critical).
When I read the file into a variable (rather then an array), the spaces do not appear, but the long URL still gets moved to the end of the output.
If I use:
open (FILE,"<$script_path/$file") || die "NFG1 $script_path/$file!\n";
@CONTENT = <FILE>;
close(FILE);
$Text::Wrap::columns = '40';
print wrap("","",@CONTENT);
The spaces show up. If I use:
open (FILE,"<$script_path/$file") || die "NFG1 $script_path/$file!\n";
while (<FILE>){
$CONTENT .= $_;
}
close(FILE);
$Text::Wrap::columns = '40';
print wrap("","",$CONTENT);
The spaces no longer appear, but again, the long URL is tossed in at the bottom. Here's how the output appears:
This program is distributed in the hope
... ## 7 lines ## ...
Artistic License for more details.
You should have received a copy of the
... ## 4 lines THIS PARAGRAPH CONTAINS THE LONG URL ## ...
glad to provide one.
You should also have received a copy of
... ## 8 lines ## ...
on the internet at
For those of you that choose to use the
... ## 40 lines ## ...
that.
##and tossed in at the end is the (split)long URL:
http://www.gnu.org/copyleft/hhhhhhhhhhh
hh/hhhhhhhhhhhhhhhhhh/gpl.html.
Very strange, all suggestions welcome
| [reply] [d/l] [select] |