Skip Menu |
 

This queue is for tickets about the Hash-Merge CPAN distribution.

Report information
The Basics
Id: 123785
Status: resolved
Priority: 0/
Queue: Hash-Merge

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

Bug Information
Severity: (no value)
Broken in: 0.299
Fixed in: 0.300



Subject: Custom behaviours in 2.99
MIME-Version: 1.0
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
Message-ID: <rt-4.0.18-7392-1511950805-1337.0-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 1232
Download (untitled) / with headers
text/plain 1.2k
The following code used to work with Hash::Merge 2.00. Since 2.99 it dies with "Behavior 'My Behavior' does not exist". The code is mostly from the module synopsis. use Hash::Merge; use Modern::Perl; my %a = ( 'foo' => 1, 'bar' => [qw( a b e )], 'querty' => { 'bob' => 'alice' }, ); my %b = ( 'foo' => 2, 'bar' => [qw(c d)], 'querty' => { 'ted' => 'margeret' }, ); # Set behaviour my $behaviour = Hash::Merge::specify_behavior( { 'SCALAR' => { 'SCALAR' => sub { $_[1] }, 'ARRAY' => sub { [ $_[0], @{ $_[1] } ] }, 'HASH' => sub { $_[1] }, }, 'ARRAY' => { 'SCALAR' => sub { $_[1] }, 'ARRAY' => sub { [ @{ $_[0] }, @{ $_[1] } ] }, 'HASH' => sub { $_[1] }, }, 'HASH' => { 'SCALAR' => sub { $_[1] }, 'ARRAY' => sub { [ values %{ $_[0] }, @{ $_[1] } ] }, 'HASH' => sub { Hash::Merge::_merge_hashes( $_[0], $_[1] ) }, }, }, 'My Behavior', ); # set global behaviour to default Hash::Merge::set_behavior('LEFT_PRECEDENT'); # Set local behaviour my $merge = Hash::Merge->new('My Behavior'); my %c = %{ $merge->merge( \%a, \%b ) };
MIME-Version: 1.0
In-Reply-To: <rt-4.0.18-7392-1511950805-1337.0-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <rt-4.0.18-7392-1511950805-1337.0-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-21360-1511951395-1242.123785-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 294
Download (untitled) / with headers
text/plain 294b
Behavior specification does not longer modify a shared document between all instances of Hash::Merge. SYNOPSIS does not tell you mix procedural and object context. Please do: my $merge = Hash::Merge->new; $merge->specify_behavior({...}, 'My Behavior'); $merge->set_behavior('My Behavior');
MIME-Version: 1.0
In-Reply-To: <rt-4.0.18-7392-1511950805-1337.0-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <rt-4.0.18-7392-1511950805-1337.0-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-30581-1520700474-301.123785-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 38
Updated API and Doc for clarification.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.