Quote:
>Hello,
>I'm using perl5.004_04. CGI.pm doesn't recognize the "wrap' attribute.
>Is this because it's an 'Extension'?
>I want to set wrap = physical, like:
> print $query->textarea(-name=>'comments',-default=>'',
> -rows=>10,-columns=>60,-wrap=>'physical');
>The lines wrap on screen within the textarea, but what gets sent to the
>server is one long line.
>I have a little loop that inserts newline after every 70 characters.
>Am I assuming correctly, or missing something here?
>Thanks,
>--irene
What is the problem exactly? CGI.pm produces the HTML code from which
the browser generates a form. When you call
print $query->textarea(-name=>'comments',-default=>'',
-rows=>10,-columns=>60,-wrap=>'physical');
Then CGI.pm only creates something like:
<TEXTAREA NAME="comments" ROWS=10 COLUMS=60 WRAP="physical">
</TEXTAREA>
This then tells the browser to physicly wrap the lines. If these lines
then subsequently are sent to the server without having been wrapped,
than this is the browsers fault, not CGI.pm's. If however, the HTML
sent to the browser is incorrect (like the WRAP attribute missing),
then CGI.pm is in the wrong.
When the data is sent from the browser to your CGI.pm script, you
cannot assume that this data will be wrapped, though. WRAP is not a
standard attribute (not even in HTML 4.0), and so not all browsers
support it. Applying wrapping after receiving it from the browser
is therefore always a good idea. Perl even has a module for it:
Text::Wrap. Just type perldoc Text::Wrap at your command line for
more information.
As a quick start:
use Text::Wrap;
Text::Wrap::colums = 70;
$wrapped = wrap('', '', $text_to_be_wrapped);
This should wrap your text neatly, at whitespace, with a maximum line
length of 70 characters.
Hope this helps.
Martijn Pieters
--
M.J. Pieters, Web Developer
| Audax Tros MultiMedia http://www.atmm.nl
| Tel: +31-35-6254545 Fax: +31-35-6254555
------------------------------------------