in reply to Re: how to splice an array?
in thread how to splice an array?

Re Re: how to splice an array?sorry for this correction, but my out put from the previous step of the program gives me the @array containing those elements as a single character.can i operate on an array rather than starting with a string.

Replies are listed 'Best First'.
Re^3: how to splice an array?
by bobf (Monsignor) on Oct 12, 2006 at 03:45 UTC

    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"; }