First, the hash assignment should be
%hash1 = {
directory1 => [ files ],
directory2 => [ files ],
directory1_subdirectory1=> [ files]
};
directory1 => [ files ],
directory2 => [ files ],
directory1_subdirectory1=> [ files]
};
# Then you can copy it with
%hash2 = %hash1;
# this should be a true copy, where changes made to one
would not affect the other
# but if you did truly want a hash
ref:
$hash_ref = \%hash1;
-----Original Message-----
From: Arul, Rex [mailto:[EMAIL PROTECTED]]
Sent: Monday, November 18, 2002 11:51
To: Perl-Win32-Users
Subject: Hash_Of_Arrays Question
From: Arul, Rex [mailto:[EMAIL PROTECTED]]
Sent: Monday, November 18, 2002 11:51
To: Perl-Win32-Users
Subject: Hash_Of_Arrays Question
I am having a Hash_Of_Arrays data structure:
$hash1 = {
directory1 => [ files ],
directory2 => [ files ],
directory1_subdirectory1=> [ files]
};Now, I need to "clone" another hash to the results so that there is a "copying" of exact contents. I know that an assignment of :
$hash2 = $hash1;
would assign a reference, which means anytime I mess with $hash2, the contents of $hash1 would get changed.
Question: How would I "clone" $hash1 to $hash2, efficiently?
Thanks,
Rex