wana said:
@my_array;
%my_hash;
@my_main_array;
push @my_main_array, {%my_hash};
%{$my_main_array[0]}{[@my_array]}++;
Argh, to quote (possibly apocryphally) Niels Bohr: "That isn't right.
It's not even wrong!"
Read my reply again, closer. $hash{[@array]} does NOT use the
reference to the anonymous array as a key! Hashes ONLY use strings as
keys! What you're doing first stringifies the reference, and then
uses THAT as the key to the hash. What this means is threefold:
1) You can't turn a stringified reference back into a reference
(possibly you could, with XS, I'm not sure, but see below).
2) Even if you could, since stringifying a reference doesn't increment
its refcount, it's possible-- likely, even-- that the thing thus
referred to wouldn't exist any longer.
3) You don't appear to be interested in reading what I have to say, or
you would have seen that I addressed that very topic as the VERY
FIRST thing I commented on!
I don't like it first of all when I spend time reading the docs
that they have on their very own hard drive to someone, but I like
it even less when I do so and they ignore me!
If you want to get help from people on this newsgroup, read the
docs FIRST, and ask questions about them if necessary, and READ
what people write when they correct you!
Is it correct to use the '++' at the end to create a value for the hash?
That's perfectly fine; why souldn't it be?
Does this give it a value of one?
It increments whatever value was there; if it was 0, (or undef, which
is 0 when treated as a number), it becomes one, yes; what do you think
happens?
I have seen this notation used commonly
with creating hash elements and I was not totally sure.
Did you think of reading the documentation, which already exists on
your hard drive, before asking other people to read it for you?
Everything you've wanted to know so far has been readily answered in
the perlref, perlreftut, and perldata manpages. I don't mind
explaining things you've read there, and didn't understand, but when
it seems that you haven't read them at all, it's very frustrating.
-=Eric