Algorithm-Hamming-Perl
view release on metacpan or search on metacpan
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;
}
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.387 second using v1.01-cache-2.11-cpan-501359838a1 )