[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] Perl Split Question
- Subject: [ale] Perl Split Question
- From: fletch at phydeaux.org (fletch at phydeaux.org)
- Date: Thu Jan 20 16:31:09 2005
>>>>> "Christopher" == Christopher Fowler <cfowler at outpostsentinel.com>
writes:
Christopher> Is there a way to use split to split a string into
Christopher> segments of N characters. I want to automatically
Christopher> wrap a long text string onto multiple lines.
Quick and dirty if you don't mind breaking in the middle of words and
being destructive to your source string (copy beforehand otherwise):
my @lines;
push @lines, substr( $str, 0, $max_len, '' ) while $str;
The CPAN way:
http://search.cpan.org/~dconway/Text-Autoformat-1.12/lib/Text/Autoformat.pm