$x = "perl monks"; for ( $i=0; $i < length($x)-1; $i++) { ($a,$b) = (split//,substr($x,$i,2)); next if $a eq " " or $b eq " "; print "$a$b "; }