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:
Update: modified codeuse strict; use warnings; my $string = "0102030405"; # will miss the last character when string is odd sized my @elements = $string =~ m/(..)/g; print "@elements\n";
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Split on every second character
by GrandFather (Saint) on Feb 12, 2010 at 23:05 UTC | |
Re^2: Split on every second character
by gri6507 (Deacon) on Feb 12, 2010 at 23:12 UTC |
In Section
Seekers of Perl Wisdom