in reply to How can I split a string into chunks of 4 characters
G'day PetreAdi,
Here's another way to do it.
#!/usr/bin/env perl -l use strict; use warnings; my $string = '01234abc'; my @chars = split // => $string; my @chunks; push @chunks, join '' => @chars[$_ .. $_ + 3] for 0 .. length($string) + - 4; print "@chunks";
Output:
0123 1234 234a 34ab 4abc
-- Ken
|
|---|