Skip Menu |

This queue is for tickets about the ExtUtils-MakeMaker CPAN distribution.

Report information
The Basics
Id: 39348
Status: resolved
Priority: 0/
Queue: ExtUtils-MakeMaker

People
Owner: Nobody in particular
Requestors: bdfoy [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 6.45_02
Fixed in: (no value)



Subject: META_MERGE overwrites no_index defaults
When I use META_MERGE to add a directory to no_index, the t and inc directories don't show up in META.yml. I've attached the sample Makefile.PL that demonstrates the problem. Although it's a minimal script, I see the same behaviour in my real Makefile.PLs. The problem is _hash_merge in MM_Any. The _hash_merge assumes only one level of reference. When I want to merge stuff into no_index, it has a value that is a hash which has a key ('directory') whose value is another hash. The second level overwrites any other value for that same key. The _hash_merge script shows this. There's probably a really simple way to fix this, but it's pretty burnt right now and I'm going to bed. I've also attached _hash_merge_fix.pl, but I haven't tested it to see if it fixes everything. For instance, do arrays have the same problem? No idea. :|
Subject: _hash_merge_fix.pl
#!/usr/bin/perl use Data::Dumper; my @hashes = ( {}, { no_index => {} }, { no_index => {directory => [] } }, { no_index => {directory => [qw(t inc)] } }, ); foreach my $hash ( @hashes ) { print "Started with: ------\n", Dumper( $hash ); my $rc = main->_hash_merge( $hash, no_index => { directory => [ qw(corpus) ] }, ); print "\nEnded with: ------\n", Dumper( $hash ), "\n===========\n"; } sub _hash_merge { my ($self, $h, $k, $v) = @_; if (ref $h->{$k} eq 'ARRAY') { push @{$h->{$k}}, ref $v ? @$v : $v; } elsif (ref $h->{$k} eq 'HASH') { foreach $vk ( keys %$v ) { $self->_hash_merge( $h->{$k}, $vk, $v->{$vk}); } # $h->{$k}{$_} = $v->{$_} foreach keys %$v; } else { $h->{$k} = $v; } }
Subject: _hash_merge.pl
#!/usr/bin/perl use Data::Dumper; my @hashes = ( {}, { no_index => {} }, { no_index => {directory => [] } }, { no_index => {directory => [qw(t inc)] } }, ); foreach my $hash ( @hashes ) { print "Started with: ------\n", Dumper( $hash ); my $rc = main->_hash_merge( $hash, no_index => { directory => [ qw(corpus) ] }, ); print "\nEnded with: ------\n", Dumper( $hash ), "\n===========\n"; } sub _hash_merge { my ($self, $h, $k, $v) = @_; if (ref $h->{$k} eq 'ARRAY') { push @{$h->{$k}}, ref $v ? @$v : $v; } elsif (ref $h->{$k} eq 'HASH') { $h->{$k}{$_} = $v->{$_} foreach keys %$v; } else { $h->{$k} = $v; } }
Subject: Makefile
Download Makefile
application/octet-stream 21.5k

Message body not shown because it is not plain text.

Subject: Makefile.PL
#!/usr/bin/perl use Data::Dumper; my @hashes = ( {}, { no_index => {} }, { no_index => {directory => [] } }, { no_index => {directory => [qw(t inc)] } }, ); foreach my $hash ( @hashes ) { print "Started with: ------\n", Dumper( $hash ); my $rc = main->_hash_merge( $hash, no_index => { directory => [ qw(corpus) ] }, ); print "\nEnded with: ------\n", Dumper( $hash ), "\n===========\n"; } sub _hash_merge { my ($self, $h, $k, $v) = @_; if (ref $h->{$k} eq 'ARRAY') { push @{$h->{$k}}, ref $v ? @$v : $v; } elsif (ref $h->{$k} eq 'HASH') { $h->{$k}{$_} = $v->{$_} foreach keys %$v; } else { $h->{$k} = $v; } }
Fixed in 6.46.