[LUNI] Help with breaking up long lines of text...

Christopher Young cyoung at ckynet.net
Fri Mar 1 12:25:06 CST 2002


Nothing worse than posting a bone head mistake to the public.
Take 2.

#!/usr/bin/perl -w
 
open(FILE, $ARGV[1]); # input_file.txt in your email
$wrap_num = $ARGV[2] - 1; # 5 in your example, minus one to offset 0 counting
while (<FILE>) {
    chomp;
    @words = split(/ /,$_);
    for ($ix = 0; $words[$ix]; $ix++) {
        print $words[$ix];
        if ($ix == $wrap_num) {
            print "\n";
            $wrap_num += $ARGV[2];
        }
    }
}
close FILE;

Hubris, slay me quickly.

/cky



More information about the luni mailing list