Algorithm-Hamming-Perl
view release on metacpan or search on metacpan
12131415161718192021222324252627282930313233if
(
@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
);
OUT
$hamcode
;
}
12131415161718192021222324252627282930313233if
(
@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
);
OUT
$data
;
}
( run in 0.399 second using v1.01-cache-2.11-cpan-1512d0f6d69 )