Re: Copying a hash-of-hashes

From: Octavian Rasnita (orasnita_at_fcc.ro)
Date: 12/31/04


To: "zentara" <zentara@highstream.net>
Date: Fri, 31 Dec 2004 13:47:31 +0200

What's the difference between using the Clone module and simply assigning
$ref1 = $ref2?

Thanks.

Teddy

----- Original Message -----
From: "zentara" <zentara@highstream.net>
To: <beginners@perl.org>
Sent: Thursday, December 30, 2004 3:45 PM
Subject: Re: Copying a hash-of-hashes

On Wed, 29 Dec 2004 22:58:17 -0500, rabbit@rabbit.us (Peter Rabbitson)
wrote:

>The question is whether there is an elegant way to produce a complete copy
>of a hash-of-hashes-of-hashes-...-of-hashes for internal subroutine
purposes
>and make sure that all references will be translated properly as well,
>leaving the subroutine no ability to modify the main hash.

#!/usr/bin/perl
use Clone qw(clone);
my $newhash = clone($hashref);

see "perldoc Clone"