in reply to Using split() to divide a string by length

This doesn't use split, but is the first thing I think of:
my $string = join '', 'a'..'z'; my @fields = $string =~ /.{1,3}/g; my @fields2 = grep {$a=!$a} @fields;
Hmm, $string =~ /.{1,3}/g should even be faster than split /(?(?{pos() % 3})(?!))/, $string.  I guess not as fast as unpack, though.

Replies are listed 'Best First'.
Re^2: Using split() to divide a string by length
by Roy Johnson (Monsignor) on Apr 13, 2006 at 21:03 UTC
    What is your grep line all about?

    Caution: Contents may have been coded under pressure.