[ale] Perl Split Question

fletch at phydeaux.org fletch at phydeaux.org
Thu Jan 20 16:31:09 EST 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




More information about the Ale mailing list