Here is one way to do it with splice and join:
use strict; use warnings; my $string = "PERLPERLPEBLPEBLPERL"; my @array = split( '', $string ); while( scalar @array ) { my $extracted = join( '', splice( @array, 0, 4 ) ); print "[$extracted]\n"; }
In reply to Re^3: how to splice an array?
by bobf
in thread how to splice an array?
by heidi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |