develooper Front page | perl.perl5.porters | Postings from February 2020

Re: Hints hash changes

Thread Previous | Thread Next
From:
David Cantrell
Date:
February 17, 2020 16:08
Subject:
Re: Hints hash changes
Message ID:
20200217160839.GA20174@bytemark.barnyard.co.uk
On Mon, Feb 17, 2020 at 11:50:26PM +1100, Tony Cook wrote:
> On Mon, Feb 17, 2020 at 10:57:56AM +0000, David Cantrell wrote:
> > Thanks to the CPAN-testers I came across a change in how the hints hash
> > is handled which I can't find documented, nor can I see any commit
> > message about it, leading me to think that the change might have been an
> > accidental side-effect.
> > 
> > It happened somewhere in between 5.31.6 and 5.31.7, as can be seen here:
> >   http://matrix.cpantesters.org/?dist=Devel-Hide+0.0012
> 
> Do you have a brief example that demonstrates the change?

Here you go:

~ $ cat Foo.pm
package Foo;

use strict;
use warnings;

sub import {
    shift;
    my @args = @_;

    foreach my $arg (@args) {
        if($arg eq '-quiet') {
            $^H{"Foo/quiet"} = 1;
        }
    }
    my $hintshash = (caller(1))[10];
    exit !$hintshash->{"Foo/quiet"}
}

1;
~ $ perlbrew switch perl-5.31.6
~ $ perl -I. -e 'use Foo qw(-quiet)';echo $?
0
~ $ perl -I. -e 'use Foo qw(pirates)';echo $?
1
~ $
~ $ perlbrew switch perl-5.31.7
~ $ perl -I. -e 'use Foo qw(-quiet)';echo $?
1
~ $ perl -I. -e 'use Foo qw(pirates)';echo $?
1

-- 
David Cantrell

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About