Perl 5.16 Support
jhulala opened this issue · comments
Current code requires Perl v5.24.
Please add support for Perl v5.16.
In general, I see no reason why my modules should support a Perl version that was published 10 years ago, so I make half of an exception here.
In 5.16 there are no signature, you have to replace all of them in the code. Together with the version number '24'. Clone this repo, apply the patch from below, then run
perl Makefile.PL
make
and if there are no errors
make test
make install
If you are using the addfile
method, you have to call it with an IO::File
object.
my $fh= IO::File->new($path, '<');
$qx->addfile($fh);
$fh->close;
And here's the patch:
diff --git a/Makefile.PL b/Makefile.PL
index 4a8bf13..ca6812c 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -16,7 +16,7 @@ my %WriteMakefileArgs = (
}
,
PREREQ_PM => {
- 'perl' => 'v5.24.0'
+ # 'perl' => 'v5.24.0'
}
,
META_MERGE => {
diff --git a/cpanfile b/cpanfile
index 40d7c18..9dbaa10 100644
--- a/cpanfile
+++ b/cpanfile
@@ -1,3 +1,3 @@
# You can install this project with curl -L http://cpanmin.us | perl - https://github.com/tekki/digest-quickxor/archive/master.tar.gz
-requires 'perl' => '5.24.0';
+requires 'perl' => '5.16.0';
test_requires 'Test::More' => '0.88';
diff --git a/lib/Digest/QuickXor.pm b/lib/Digest/QuickXor.pm
index 3d5f3d9..3b8aa18 100644
--- a/lib/Digest/QuickXor.pm
+++ b/lib/Digest/QuickXor.pm
@@ -4,9 +4,9 @@ use parent qw|DynaLoader|;
use strict;
use warnings;
use utf8;
-use v5.24;
-use feature 'signatures';
-no warnings 'experimental::signatures';
+use v5.16;
+# use feature 'signatures';
+# no warnings 'experimental::signatures';
use Carp 'croak';
use Exporter 'import';
@@ -18,13 +18,15 @@ __PACKAGE__->bootstrap($VERSION);
# functions
-sub quickxorhash (@data) {
+sub quickxorhash {
+ my @data = @_;
return __PACKAGE__->new->add(@data)->b64digest;
}
# constructor
-sub new ($class) {
+sub new {
+ my ($class) = @_;
my $qx = Digest::QuickXor::HashPtr->new();
my $self = {_qx => $qx};
@@ -33,7 +35,8 @@ sub new ($class) {
# methods
-sub add ($self, @data) {
+sub add {
+ my ($self, @data) = @_;
for (@data) {
$self->{_qx}->add($_, length $_);
}
@@ -41,7 +44,8 @@ sub add ($self, @data) {
return $self;
}
-sub addfile ($self, $fh) {
+sub addfile {
+ my ($self, $fh) = @_;
croak 'Not a file handle!' unless $fh->can('sysread');
my $ret = '';
@@ -53,14 +57,16 @@ sub addfile ($self, $fh) {
return $self;
}
-sub b64digest ($self) {
+sub b64digest {
+ my ($self) = @_;
my $rv = $self->{_qx}->b64digest;
$self->reset;
return $rv;
}
-sub reset ($self) {
+sub reset {
+ my ($self) = @_;
$self->{_qx}->reset;
return $self;
diff --git a/t/01-object.t b/t/01-object.t
index 285f634..254c9a0 100644
--- a/t/01-object.t
+++ b/t/01-object.t
@@ -1,7 +1,7 @@
use strict;
use warnings;
use utf8;
-use v5.24;
+use v5.16;
use Test::More;
diff --git a/t/02-text.t b/t/02-text.t
index d9df9f9..6d4a3eb 100644
--- a/t/02-text.t
+++ b/t/02-text.t
@@ -1,7 +1,7 @@
use strict;
use warnings;
use utf8;
-use v5.24;
+use v5.16;
use Test::More;
diff --git a/t/03-file.t b/t/03-file.t
index b5f3eef..23c957e 100644
--- a/t/03-file.t
+++ b/t/03-file.t
@@ -1,7 +1,7 @@
use strict;
use warnings;
use utf8;
-use v5.24;
+use v5.16;
use FindBin;
use Test::More;
@@ -30,15 +30,15 @@ for my $file (sort keys %hashes) {
my $fh;
my $path = "$FindBin::Bin/resources/$file";
- ok open($fh, '<', $path), "Glob for $file";
- is $object->addfile($fh)->b64digest, $hashes{$file}, "Hash for $file glob";
- close $fh;
+ # ok open($fh, '<', $path), "Glob for $file";
+ # is $object->addfile($fh)->b64digest, $hashes{$file}, "Hash for $file glob";
+ # close $fh;
ok $fh= IO::File->new($path, '<'), "Handle for $file";
is $object->addfile($fh)->b64digest, $hashes{$file}, "Hash for $file handle";
$fh->close;
- eval { $object->addfile($path) };
+ eval { $object->addfile(bless {}, 'SomeClass') };
like $@, qr/Not a file handle!/, 'Correct error for path';
}
diff --git a/t/04-function.t b/t/04-function.t
index 46cb2bb..53b5705 100644
--- a/t/04-function.t
+++ b/t/04-function.t
@@ -1,7 +1,7 @@
use strict;
use warnings;
use utf8;
-use v5.24;
+use v5.16;
use Test::More;
Closing this issue because there is no feedback after one month.