Hmm, strange. According to the source code log, i'm using "diagnostics" in many of my programs since at least October 2018, which by my reckoning was Perl 5.24. Never seen that one before.
Could you do me a favor? Since i can't reproduce the error, could you test the following and post the output? Just to make sure that i can update CPAN and make diagnostics optional.
use 5.010_001; use strict; use warnings; use diagnostics; my $diagnosticsenabled; BEGIN { $diagnosticsenabled = 0; eval { use diagnostics; $diagnosticsenabled = 1; }; } if(!$diagnosticsenabled) { print "'use diagnostics' is not available, you will not get detail +ed error messages.\n"; } else { print "diagnostics module loaded!\n"; }
Until you find a solution, you can safely delete the "diagnostics" line. In fact, you can reduce the whole Contains.pm to:
package Array::Contains; use 5.010_001; use strict; use warnings; our $VERSION = 2.8; use Carp; require Exporter; our @ISA = qw(Exporter); our @EXPORT = qw(contains); sub contains { my ($value, $dataset) = @_; if(!defined($value)) { croak('value is not defined in contains()'); } if(!defined($dataset)) { croak('dataset is not defined in contains()'); } if(ref($value) ne '') { croak('value is not a scalar in contains()'); } if(ref($dataset) ne 'ARRAY') { croak('dataset is not an array reference in contains()'); } foreach my $key (@{$dataset}) { next if(ref($key) ne ''); if($value eq $key) { return 1; } } return 0; }
I mean, technically if you plan to make no errors calling the function, you can strip the whole thing down even further (untested and not recommended):
package Array::Contains; use 5.010_001; use strict; use warnings; our $VERSION = 2.8; require Exporter; our @ISA = qw(Exporter); our @EXPORT = qw(contains); sub contains { my ($value, $dataset) = @_; foreach my $key (@{$dataset}) { next if(ref($key) ne ''); if($value eq $key) { return 1; } } return 0; }
In reply to Re: diagnostics pragma throwing a compile-time error in Cygwin-Perl
by cavac
in thread diagnostics pragma throwing a compile-time error in Cygwin-Perl
by Intrepid
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |