in reply to Re^3: Combining client phone lists
in thread Combining client phone lists

I'm trying to make a list of those clients who have more than one phone number, so that the output would be something like this:

Bob Cartwright 8219870089 Bob Wilson 3324549932, 8888212248 Felix Harris 4333448711 Freddie Sonere 4429089 Gloria Simpson 8215449341 Sam Burr 4550327 Wanda Smith 4449721, 3324329887 Clients with multiple phone numbers: Bob Wilson 3324549932, 8888212248 Wanda Smith 4449721, 3324329887

Replies are listed 'Best First'.
Re^5: Combining client phone lists
by GrandFather (Saint) on Apr 20, 2007 at 05:43 UTC

    So you want reporting code like:

    my @single = grep {keys (%{$bigList{$_}}) == 1} keys %bigList; my @multi = grep {keys (%{$bigList{$_}}) > 1} keys %bigList; for my $one (@single) { print "$one ", join ', ', sort {$a <=> $b} keys %{$bigList{$one}}; print "\n"; } print "\n\nClients with multiple phone numbers:\n\n"; for my $one (@multi) { print "$one ", join ', ', sort {$a <=> $b} keys %{$bigList{$one}}; print "\n"; }

    Prints:

    Gloria Simpson 8215449341 Sam Burr 4550327 Freddie Sonere 4429089 Felix Harris 4333448711 Bob Cartwright 8219870089 Clients with multiple phone numbers: Bob Wilson 3324549932, 8888212248 Wanda Smith 4449721, 3324329887

    DWIM is Perl's answer to Gödel
      Grep....of course! Sometimes when you finally see how to have gotten something done you want to kick yourself for not having figured it out.

      Perl seems to fight me, but a little at a time the edges are softening.

      Thank you so much for your help! 8^}
Re^5: Combining client phone lists
by naikonta (Curate) on Apr 20, 2007 at 05:44 UTC
    Eh? I think I'm lost. Is your last reply a testimonial or a further question? As far as I can see, GrandFather already answered your problem exactly as you want.

    Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!