line wrapping
am 28.01.2008 19:34:31 von Shion
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?
Re: line wrapping
am 28.01.2008 19:45:18 von Ron Bergin
On Jan 28, 10:34 am, monkeys paw 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
Re: line wrapping
am 28.01.2008 21:23:23 von Jim Gibson
In article <5vGdncn_6fOtvQPanZ2dnUVZ_rignZ2d@insightbb.com>, monkeys
paw 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