in reply to How can I split a string into chunks of 4 characters
my @array = map { substr $string, $_, 4 } 0 .. length( $string ) +- 4;
If the string is really long, use a $position variable and a while loop so that internally the big 0 .. length( $string ) - 4 list doesn't need to be built and stored:
my $pos = 0; while( $pos <= length( $string ) - 4 ) { push @array, substr( $string, $pos++, 4 ); }
Dave
|
|---|