http://www.perlmonks.org?node_id=822949


in reply to Split on every second character

If you are sure that the string is even sized, you can use a simple regex like this:

use strict; use warnings; my $string = "0102030405"; # will miss the last character when string is odd sized my @elements = $string =~ m/(..)/g; print "@elements\n";
Update: modified code