Perl - Need help on splitting string

Let's say I have a very long string with no spaces but just words stored in $very_long_string.

$very_long_string = "aaaaaaaaaaabbbbbbbbbbbccccccccccccdddddddddddd";

I can do this to split the string into 1 character each and store them in an array:
@myArray = split(//, $very_long_string);

If instead I want to split $very_long_string into 2 characters, how would I do that? 3 characters? Or more?

You don't want to use the split() function unless (as you are doing) you want to split all the characters (no delimiter) or there is a well defined delimiter to split on. What you can do is use a matching regexp and a caturing group () to populate the array per your requirements:

$very_long_string = "aaaaaaaaaaabbbbbbbbbbbccccccccccccdddddddddddd";
@array = $very_long_string =~ /(.{1,2})/g;
print "$_\n" for @array;

where '.' is any character and {1,2} is a quantifier meaning 1 minimum, 2 maximum, character per matched group. The 'g' on the end tells the regexp to perform the match over the entire string. Replace 2 with 3 to match in group of three (or less).

Thank you.

$var="abcdefghijklmnopqrstuvw";
$var=reverse $var;
@arr=split(/(?=(?:..)+$)/,$var);
@arr=reverse @arr;
for($i=0;$i<=$#arr;$i++){
	$arr[$i]=reverse $arr[$i];
}
print join "-",@arr;