in reply to Re: A Little String Help Please
in thread A Little String Help Please

The part generation code can be condensed a little through use of a regex:

use strict; use warnings; my $n = shift; my $text = do {local $/; <DATA>}; $text =~ s/\n/ /g; my @lines = $text =~ /(.{1,$n})\s+/g; print "$_\n" for @lines; __DATA__

which generates the same output given the same input as the sample above.


DWIM is Perl's answer to Gödel

Replies are listed 'Best First'.
Re^3: A Little String Help Please
by johngg (Canon) on May 06, 2007 at 22:58 UTC
    ... can be condensed a little ...

    I'd say that was condensing it quite a lot :)

    A much simpler approach, I wish I'd thought of it.

    Cheers,

    JohnGG