On Wed, Jan 23, 2002 at 01:53:55PM -0500, Yanick wrote:
>  Shorterer:
> 
>         @ary = $foo =~ /..?.?/g;

Longer:

@ary = grep $_ ne "", split /(...)/, $foo;

push @ary, substr $foo, 0, 3, '' while $foo ne '';

@ary = unpack "a3" x ((length "${foo}xx")/3), $foo;

@ary = map {substr $foo, $_*3, 3} (0..((length $foo)/ 3));

@ary = map {substr $foo, $_, 3 } grep { !($_ % 3) } (0..length $foo);

for ($i=0; $i <= length $foo; $i+=3) { push @ary, substr $foo, $i, 3 }

@c = split //, $foo; push @ary, (shift @c) . (shift @c) . (shift @c) while @c;

-- 
zed at-sign apricot dot com                http://www.apricot.com/~zed/
Zed Lopez                                  PO Box 12546 Berkeley CA 94712

Reply via email to