Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: Counting Data in two columns?

by sdslrn123 (Novice)
on Jun 15, 2006 at 13:52 UTC ( [id://555501]=note: print w/replies, xml ) Need Help??


in reply to Re: Counting Data in two columns?
in thread Counting Data in two columns?

Thank You, everyone for your help! I am just confused with the following example. I think it is an inverted form of the original example I performed:
%HoA = ( flintstones => [ "fred", "barney" ], jetsons => [ "fred", "jane", "elroy" ], simpsons => [ "fred", "marge", "bart" ], );
If the family names (jetsons, simpsons) are always different but elements within each of the familes may or may not match. If I want to show that:
"fred" is a name that can be found in 3 families = [flintstones, jetso +ns, simpsons] e.t.c
Is this possible with this hash formation?

Replies are listed 'Best First'.
Re^3: Counting Data in two columns?
by neniro (Priest) on Jun 15, 2006 at 14:00 UTC
    #!/usr/bin/perl use strict; use warnings; use Data::Dumper; my %hoa = ( flintstones => [ "fred", "barney" ], jetsons => [ "fred", "jane", "elroy" ], simpsons => [ "homer", "marge", "bart" ], ); my @freds = grep { $hoa{$_}->[0] eq 'fred' } sort keys %hoa; print Dumper \@freds;
      Thank You. But is grep an unix command? Unfortunately, I do not use Unix?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://555501]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-04-16 21:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found