Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Groups of Objects with Common Attributes

by martink (Initiate)
on May 16, 2018 at 05:15 UTC ( [id://1214607] : note . print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    1 4 round apple,ball,orange,pumpkin
    2 2 red,round apple,ball
    ...
    4 1 fruit,orange,plant,round orange
    4 1 fruit,plant,red,round apple
    4 1 orange,plant,round,vetetable pumpkin
    
  2. or download this
    my $item2attr = {
                apple   => {red=>1,   round=>1,plant=>1,fruit=>1},
    ...
      }
      return sort @shared_items;
    }