unpack '(a8)*', $str # Supports incomplete blocks $str =~ /.{8}/sg $str =~ /.{1,8}/sg # Supports incomplete blocks