Algorithm-Hamming-Perl

 view release on metacpan or  search on metacpan

example03  view on Meta::CPAN

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
if (@ARGV < 2) {
        die "USAGE: ./example03 infile outfile\n";
}
 
$infile = $ARGV[0];
$outfile = $ARGV[1];
 
### Open filehandles
open(IN,"$infile") || die "ERROR: Can't open $infile: $!\n";
open(OUT,">$outfile") || die "ERROR: Can't open $outfile: $!\n";
binmode(IN);
binmode(OUT);
 
### Use optional faster (but bigger) cache - adds several seconds to startup!
Algorithm::Hamming::Perl::hamming_faster();
 
 
### Process data
while (read(IN,$buffer,3072)) {
        $hamcode = hamming($buffer);
        print OUT $hamcode;
}

example04  view on Meta::CPAN

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
if (@ARGV < 2) {
        die "USAGE: ./example04 infile outfile\n";
}
 
$infile = $ARGV[0];
$outfile = $ARGV[1];
 
### Open filehandles
open(IN,"$infile") || die "ERROR: Can't open $infile: $!\n";
open(OUT,">$outfile") || die "ERROR: Can't open $outfile: $!\n";
binmode(IN);
binmode(OUT);
 
### Use optional faster (but bigger) cache - adds several seconds to startup!
Algorithm::Hamming::Perl::hamming_faster();
 
 
### Process data
while (read(IN,$buffer,3072)) {
        $data = unhamming($buffer);
        print OUT $data;
}



( run in 0.399 second using v1.01-cache-2.11-cpan-1512d0f6d69 )