in reply to constant.pm + index() + Pod::Coverage crashes on Perl 5.10

Hi Henning, Perl-Monks,

we just encountered the same problem. I think it's a bug in the Perl compiler as constant.pm does not do anything illegal concerning the symbol table.

And just compiling the index function should not have an effect of the contents of the symbol table.

Here's a short script to verify the error. Also includes a Workaround to use the "&" prefix for the constant when used inside the index call.

#!/usr/bin/perl use strict; use warnings; use constant ABC => 'abc'; use constant CDE => 'cde'; use Data::Dumper; # print the constants value before the sub below has been compiled # results in $VAR1 = 'abc' BEGIN { print Dumper( ABC ); print Dumper( CDE ); } # this is in a sub to show that it's not necessary # to actually call index to change the constants behaviour sub some1 { index( shift, ABC ) }; # prefixing the constant with an "&" prevents the error sub some2 { index( shift, &CDE ) }; # print the constants value after sub some has beenn compiled # results in $VAR1 = *bc; print Dumper( ABC ); print Dumper( CDE );
We don't use index a lot, but would be nice to see this fixed. Cheers, Stefan Riss

Replies are listed 'Best First'.
Re^2: constant.pm + index() + Pod::Coverage crashes on Perl 5.10
by Corion (Patriarch) on Dec 18, 2015 at 10:27 UTC

    For which Perl version do you get these results? When I run your program on Perl 5.20, I get the following output, which is what I expect:

    c:\Users\Corion\Projekte>perl -w tmp.pl $VAR1 = 'abc'; $VAR1 = 'cde'; $VAR1 = 'abc'; $VAR1 = 'cde';

    If you're waiting for a bug to be fixed for Perl 5.10, just upgrade to something newer. According to perlpolicy, Perl 5.10 is out of support since at least 2011.

      Hi Corion, much appreciate you looking into this. Sorry for not attaching the Perl version. This is indeed 5.10 and yes I can confirm that it has been fixed somewhere between 5.14.2 and 5.18.1 which are the versions currently available to me. We are in the process of upgrading the hardware and Perl with it ;), so it's good to know that this has been fixed. Thanks again. Best regards, Stefan