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; }

PerlMonks XP is useless? Not anymore: XPD - Do more with your PerlMonks XP
Also check out my sisters artwork and my weekly webcomics

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.