Algorithm-Hamming-Perl

 view release on metacpan or  search on metacpan

example03  view on Meta::CPAN

#!/usr/bin/perl
#
# example03 - example of data to hamming code converter.
#
# USAGE: ./example03 infile outfile
#
# 18-Oct-2003	Brendan Gregg	Created this.

use Algorithm::Hamming::Perl  qw(hamming unhamming unhamming_err);

### Check args
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);

example04  view on Meta::CPAN

#!/usr/bin/perl
#
# example04 - example of hamming code to data converter.
#
# USAGE: ./example04 infile outfile
#
# 18-Oct-2003	Brendan Gregg	Created this.

use Algorithm::Hamming::Perl  qw(hamming unhamming unhamming_err);

### Check args
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);



( run in 0.242 second using v1.01-cache-2.11-cpan-4d50c553e7e )