"abcd" =~ /(..) (?{push @pairs, $1}) (*FAIL)/xs; say "@pairs"; __END__ ab bc cd