Hardly Armchair am Donnerstag, 14. September 2006 00:00:
> [EMAIL PROTECTED] wrote:
> > There is something you're not telling us about the contents of these
> > hashes.
>
> Sorry, %p_mod looks like this:
[...see in script below]
> > My best guess (since you make us guess) is that you're looking for a
> > deep copy because the values of %p_mod are actually references.
>
> I was unaware that this made a difference, thus the insufficient
> information.  How do I proceed?

Besides Storable::dclone, there is also Clone::clone; in my experience, 
Clone::clone is much faster; you can benchmark the two clone subs in your 
particular context:

#!/usr/bin/perl

use strict;
use warnings;

#!/usr/bin/perl

use strict; use warnings;

use Clone qw(clone);
use Storable qw(dclone);

use Benchmark qw(timethese);

my %p_mod = (
           'A' => {
                   'fingers' => {
                                 '4' => 'ABSFMQS',
                                 '5' => 'SMTFQNL',
                                },
                   'name'    => '8-H34'
                  },
           'C' => {
                   'fingers' => {
                                 '1' => 'ALEJIEK',
                                 '2' => 'BESLERJ',
                                },
                   'name'    => '9-J09'
                  },
           'B' => {
                   'fingers' => {
                                 '3' => 'OLPWJEK',
                                },
                   'name'    => '6-G79'
                  }
          );


timethese(100_000, {
  'Clone'    => sub { my %copy=%{ clone(\%p_mod) } },
  'Storable' => sub { my %copy=%{ dclone(\%p_mod) } },
})
  for (1..100);

__END__


Dani

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to