Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^3: Minimize Hash Key Value Combinations

by hdb (Monsignor)
on Nov 18, 2013 at 14:40 UTC ( [id://1063104]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Minimize Hash Key Value Combinations
in thread Minimize Hash Key Value Combinations

Here is my attempt:

use strict; use warnings; use Data::Dumper; my @data = map { [ [split /,\s*/, $_->[0]], [split /,\s*/, $_->[1]] ] } map { /\[(.*)\]\s*=>\s*\[(.*)\]/ ? [ $1, $2 ] : () } <DATA>; my %inverted; for my $d (@data) { undef @{$inverted{$_}}{@{$d->[0]}} for @{$d->[1]}; } my %invertagain; push @{ $invertagain{join ",", sort keys %{$inverted{$_}}} }, $_ for k +eys %inverted; print Dumper \%invertagain; __DATA__ [a, b, c] => [1, 2, 3] [b, c] => [2, 3, 4, 5] [a, c, d] => [4, 5, 6, 7] [d] => [1, 2, 6]

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-04-19 15:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found