Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: diagnostics pragma throwing a compile-time error in Cygwin-Perl

by cavac (Prior)
on Apr 16, 2025 at 11:41 UTC ( [id://11164734]=note: print w/replies, xml ) Need Help??


in reply to diagnostics pragma throwing a compile-time error in Cygwin-Perl

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

Replies are listed 'Best First'.
Re^2: diagnostics pragma throwing a compile-time error in Cygwin-Perl
by Haarg (Priest) on Apr 16, 2025 at 13:31 UTC
    diagnostics should never be used in a module released on CPAN. It has a number of global impacts that users won't expect.
Re^2: diagnostics pragma throwing a compile-time error in Cygwin-Perl
by Intrepid (Deacon) on Apr 16, 2025 at 16:32 UTC

    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.

    Sure thing. You are doing me a favor after all. We're collaborating, the best thing to do on PMo. This is what is output:

    $ perl ./testcode-cavac.pl
    couldn't find diagnostic data in /usr/share/perl5/5.40/pods/perldiag.pod /usr/local/lib/perl5/site_perl/5.40/x86_64-cygwin-threads /usr/local/share/perl5/site_perl/5.40 /usr/lib/perl5/vendor_perl/5.40/x86_64-cygwin-threads /usr/share/perl5/vendor_perl/5.40 /usr/lib/perl5/5.40/x86_64-cygwin-threads /usr/share/perl5/5.40 testcode-cavac.pl at /usr/share/perl5/5.40/diagnostics.pm line 259, <POD_DIAG> line 718.
    Compilation failed in require at testcode-cavac.pl line 10.
    BEGIN failed--compilation aborted at testcode-cavac.pl line 10.

    Same message as with the simplest test case I posted above. BTW, I think you meant to remove line 4, use diagnostics; which comes before the code you added. I tried deleting it but it made no difference.

    If it isn't essential to the functioning of the module, for CygwinPerl I'll do what you recommended which is to not have diagnostics at all.

    Apr 16, 2025 at 16:32 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11164734]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2025-06-19 12:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.