This is probably what you are looking for:
use strict;
my %byColor;
while (<DATA>){
my ($fruit, @colors) = split;
for my $c(@colors){
push @{ $byColor{$c} }, $fruit;
}
}
for my $c(sort keys %byColor){
print "$c\t @{$byColor{$c}}\n";
}
__DATA__
strawberry red green rose
apple red rose
mango green
Output:
green strawberry mango
red strawberry apple
rose strawberry apple
My goal ... to kill off the slow brain cells that are holding me back from synergizing my knowledge of vertically integrated mobile platforms in local cloud-based content management system datafication.