#!/usr/bin/perl use strict; use warnings; use Text::Ngram qw/ngram_counts/; $|++; my @p = qw/a c g t/; my $test_seq = join( '', map { $p[rand @p] } 0..2047 ); my $counter = 0; while ( 1 ) { my $href = ngram_counts( $test_seq ); my $ngrams = scalar keys %$href; if ( ++$counter % 100 == 0 ) { printf( "found %4d 5-grams on iteration # %8d\r", $ngrams, $counter ); $test_seq = join( '', map { $p[rand @p] } 0..2047 ); } }