#!perl
#use Cat;
use Storable qw(dclone);
my $buster = Cat->new(
name => 'Buster',
colors => [ qw(black white) ]
);
my $original = [ $buster, qw( Ginger Mimi Ella ) ];
my $copy = dclone $original;
$copy->[0]->set_name( 'Roscoe' );
printf "In \$original, the first cat's name is %s\n", $original->[0]->get_name;
printf "In \$copy, the first cat's name is %s\n", $copy->[0]->get_name;
BEGIN {
package Cat;
sub new {
my( $class, %hash ) = @_;
bless \%hash, $class;
}
sub set_name { $_[0]->{name} = $_[1] }
sub get_name { $_[0]->{name} }
}