in reply to What is the best solution to swap input data?
Using a regex is a little more compact:
use strict; use warnings; my $str = '12345678'; $str =~ s/(.)(.)/$2$1/g; print $str;
Prints:
21436587
Update: BTW, using $a and $b as variables is a bad idea. They are the variables used by sort.
|
|---|