Subject: | Accidental sharing of data between instances |
Due to add_release($params) keeping a reference to $params, calling add_release($params) on 2 different objects with the same $params hash means later modificatons are shared.
In this example, you'll see that after adding changes to a, those same changes are added to b accidentally, due to sharing the same initial params hash.
In this example, you'll see that after adding changes to a, those same changes are added to b accidentally, due to sharing the same initial params hash.
Subject: | x.pl |
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use CPAN::Changes;
my $a = CPAN::Changes->new();
my $b = CPAN::Changes->new();
my $params = { version => '1.0'};
$a->add_release($params);
$b->add_release($params);
my ( @changes ) = (
"hello"
);
$a->release('1.0')->add_changes(@changes);
print $b->serialize;