Here is make_test.pl

use strict; use warnings; use Getopt::Long; use List::Util qw(min); use vars qw/$Fuzz $Words $Word_Size $Strings $String_Size $OverWrite/; exit(main()); BEGIN { $Fuzz=2; $Words=1000; $Word_Size=25; $Strings=100; $String_Size=1000; $OverWrite=0; } sub opts_msg { warn @_,"\nLegal Opts (with defaults):\n\t--fuzz=$Fuzz --words=$Word +s --strings=$Strings\n". "\t--word_size=$Word_Size --string_size=$String_Size \n". "\t--over_write --verbose\n"; 1; } sub main { $|++; my $help; my $VERBOSE; GetOptions('fuzz=i' => \$Fuzz, 'words=i' => \$Words, 'strings=i' => \$Strings, 'word_size=i' => \$Word_Size, 'string_size=i'=> \$String_Size, 'over_write!' => \$OverWrite, 'verbose!' => \$VERBOSE, 'help' => \$help) or return opts_msg("Bad Option Provided."); return opts_msg() if $help; my @Chars=qw(A C G T); my $file=sprintf "FT-SC%04d-SL%07d-F%02d-WC%07d-WL%03d.fuzztest", #map { $_>=1000 ? int($_/1000)."k" : $_ } $Strings,$String_Size,$Fuzz,$Words,$Word_Size; if (!$OverWrite and -e $file) { warn "Test file '$file' exists already\n"; warn "Use --over_write to force\n"; print $file,"\n"; return 1; } open my $fh,">",$file or die "Error writing to '$file':$!"; warn "Writing '$file'\n" if $VERBOSE; # Header print $fh '$Fuzz,$Words,$Word_Size,$Strings,$String_Size,$chars',"\n +"; print $fh "$Fuzz,$Words,$Word_Size,$Strings,$String_Size,",@Chars,"\ +n"; # Words my @words; my $count=$String_Size/$Word_Size/2; warn "With $Words words of $Word_Size random chars: (@Chars)\n" if $VERBOSE; for (1..$Words) { my $str=join "",map { $Chars[rand @Chars] } 1..$Word_Size; if (@words<$count) { push @words,$str; } else { $words[rand @words]=$str unless int rand $count/2; } print $fh $str,"\n"; } print $fh "---\n"; # Strings warn "And $Strings random strings of length $String_Size\n" if $VERBOSE; for (1..$Strings) { my $str="A" x $String_Size; substr($str,$_,1,$Chars[rand @Chars]) for 0..$String_Size-1; for (1..$count) { my $p=int rand($String_Size-$Word_Size); my $w=$words[rand @words]; substr($w,int(rand length $w),1)=$Chars[rand @Chars] for 1..rand $Fuzz+1; substr($str,$p,$Word_Size,$w); } print $fh $str,"\n" } close $fh or die "Failed to close '$file'\n"; warn "Done.\n" if $VERBOSE; print $file,"\n"; return 0; }
---
demerphq


In reply to Re^2: Algorithm Showdown: Fuzzy Matching (Files) by demerphq
in thread Algorithm Showdown: Fuzzy Matching by demerphq

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.