line wrapping

I have entries typed in by clients that need to wrap.
If a client were to type in a string of chars (say 100) without a space,
i need a substitution that would insert a break and newline at space
80. How would one do that with a s/// type statement?
Shion [ Mo, 28 Januar 2008 19:34 ] [ ID #1918538 ]

Re: line wrapping

On Jan 28, 10:34 am, monkeys paw <u... [at] example.net> wrote:
> I have entries typed in by clients that need to wrap.
> If a client were to type in a string of chars (say 100) without a space,
> i need a substitution that would insert a break and newline at space
> 80. How would one do that with a s/// type statement?

use Text::Wrap
http://search.cpan.org/~muir/Text-Tabs+Wrap-2006.1117/lib/Te xt/Wrap.pm
Ron Bergin [ Mo, 28 Januar 2008 19:45 ] [ ID #1918540 ]

Re: line wrapping

In article <5vGdncn_6fOtvQPanZ2dnUVZ_rignZ2d [at] insightbb.com>, monkeys
paw <user [at] example.net> wrote:

> I have entries typed in by clients that need to wrap.
> If a client were to type in a string of chars (say 100) without a space,
> i need a substitution that would insert a break and newline at space
> 80. How would one do that with a s/// type statement?

One would use substr, rather than an RE:

substr($entry,80,0,"\n");

If one insisted on using REs:

$entry =~ s/^(.{80})/$1\n/;

Note: a "newline" is assumed to be the desired "break" here.

For larger jobs, the Text::Wrap module is recommended.

--
Jim Gibson

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Jim Gibson [ Mo, 28 Januar 2008 21:23 ] [ ID #1918544 ]
Perl » comp.lang.perl.misc » line wrapping

Vorheriges Thema: Version 5.8.8.8 html docs are shifted over (hidden) about 4 or 5 pixels to the left off the frame. W
Nächstes Thema: FAQ 9.20 How do I send mail?