use strict; use warnings; while(){ my$max=0; s/$/, /; my$x=()=/,/g; for my$n(1..$x){ if(/^((?:\d+, ){$n})\1+$/){ $max=$n;last; } } print$/,($max>0?$x/$max:0); } __DATA__ 1, 2, 5, 1, 2, 5, 1, 2, 5 3, 6, 3, 6, 3, 6, 3, 6 4, 1, 28, 0, 4, 1, 28, 0 3, 5, 17, 3, 17, 5 4, 1, 28, 0, 4, 1, 28