Your array code is assuming that @array contains an array where each element is one letter from the string, which is not what it contains. You can make it contain that by using @array = split( '', "PERLPERLPEBLPEBLPERL" ); or you can just understand that you are dealing with a string, not an array, and take a different approach, such as...
my $string = "PERLPERLPEBLPEBLPERL"; my @answer = ( $string =~ m/(.{4})/g ); print "@answer\n";
| We're not surrounded, we're in a target-rich environment! |
|---|
In reply to Re: how to splice an array?
by jasonk
in thread how to splice an array?
by heidi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |