# substr no good, this is a simplified regexp while( ($b, $c) = $a =~ /(.)(.)/g ){ #do stuff }