# file containing mix of 0s and 1s perl -le 'srand(); my $f = 0; foreach my $i ( 1 .. 50 ) { if ( $i % 5 == 0 ) { $f++; $f %= 2; } print $f; }' > file_mix.txt