in reply to Re: Common elements of a hash of hashes
in thread Common elements of a hash of hashes

my %HoH = %{+shift};

Did I miss something? I don't see the word "shift" in the entire thread. Anyway, that takes the first parameter, dereferences it as a hashref and assigns the resulting hash to %HoH. The plus sign is needed for preventing Perl to take $shift as a reference and instead use the shift function. shift without arguments operates on @_ (UPDATE: or @ARGV depending on the scope).

lc is "lowercase". I'm not sure about the comma.

grep { $count!=$count{$_} } map { ++$count{$_};$_ } map { keys %{$HoH{$_}} } keys %HoH
the result of this line is stored in which variable?

That returns a list but, since it's surrounded with [ and ], the for loop gets a reference to that list. It's not stored anywhere. It's visible inside the loop as $_.

I see it the other way around, that is, s/obscure/brilliant/.

--
David Serrano

  • Comment on Re^2: Common elements of a hash of hashes

Replies are listed 'Best First'.
Re^3: Common elements of a hash of hashes
by blazar (Canon) on Oct 09, 2005 at 09:14 UTC
    lc is "lowercase". I'm not sure about the comma.
    It's there because of this:
    $ cat foo.pl my %a; $_='fOo'; $a{lc}++; $a{lc()}++; $a{+lc}++; $a{lc,}++; $ perl -MO=Deparse foo.pl my %a; $_ = 'fOo'; ++$a{'lc'}; ++$a{lc $_}; ++$a{lc $_}; ++$a{lc $_}; foo.pl syntax OK
    So it's there for disambiguating too, just as +shift. I chose the latter form because in this context (involving the ++ operator) it seemed to me to be the least obtrusive and visually distracting.