TechCrazy said:
I have copy of Perl Little Black Book which does not talk about the
following. So, I am asking this question here:
For,
my $hh = %hash;
%hash is a hash of hashes. Would the statement above
1) create a copy of %hash and assign it to hh
You don't have a 'hh' variable, you have '$hh'. So this is
impossible. For your statement above to be true, you'd have to write
something like:
my %hh = %hash;
Note the important '%' instead of '$'.
OR
2) only a reference is created.
You only get a reference when you explicitly ask for one, which you
didn't do there. If you read 'perldoc perldata', you will see:
If you evaluate a hash in scalar context, it returns false if
the hash is empty. If there are any key/value pairs, it
returns true; more pre- cisely, the value returned is a string
consisting of the number of used buckets and the number of
allocated buckets, separated by a slash.
This documentation is included in your Perl distribution, and people
around here get somewhat testy in general when asked to read to
someone the documentation already on their own system. To avoid this
sort of reaction, I strongly recommend you familiarize yourself with
the contents of the FAQ ('perldoc perlfaq'), and at least enough of
the rest of the documentation ('perldoc perltoc') to know where to
look up the answers yourself first, before asking others.
Oh yeah, another question you'll see around here a lot when you ask a
question like that one: What happened when you tried it? You've got a
Perl interpreter on your machine (if not, then install one), so why
ask several hundred people to do for you something you can easily ask
Perl to do in a few nanoseconds, tops?
-=Eric