#! perl -slw use strict; use Data::Dump qw[ pp ]; { my @x = (0x00011011) x 24; my $x = 0; sub srand8 { $x = $_[0] % 24; } sub rand8{ $x = ++$x % 24; $x[ $x ] = ( $x[ $x ] * 33 + 251 ) & 255; return $x[ $x ]; } } our $L //= 1e4; our $S //= 1; srand8( $S ); my $s = ''; $s .= pack 'C*', map rand8(), 1 .. 256 for 1 .. ($L/256+1); print length $s; $s =~ m[(.{256}).*?(\1)]sm and print "Sequence at [ $-[1], $-[1] ] repeats at [ $-[2], $+[2] ]"; __END__ C:\test>rand8 -S=1 10240 Sequence at [ 0, 0 ] repeats at [ 6144, 6400 ] C:\test>rand8 -S=2 10240 Sequence at [ 0, 0 ] repeats at [ 6144, 6400 ] C:\test>rand8 -S=3 10240 Sequence at [ 0, 0 ] repeats at [ 6144, 6400 ] C:\test>rand8 -S=4 10240 Sequence at [ 0, 0 ] repeats at [ 6144, 6400 ] C:\test>rand8 -S=5 10240 Sequence at [ 0, 0 ] repeats at [ 6144, 6400 ] C:\test>rand8 -S=255 10240 Sequence at [ 0, 0 ] repeats at [ 6144, 6400 ]