#!/usr/bin/perl use strict; use warnings; my %colors=( "life" , "white or black", "cat" , "black", "horse" , "white or black", "blood", "red", "sky" ,"blue"); foreach my $coloredThing (keys %colors) { print "$coloredThing "; if ($colors{$coloredThing}=~m/(black|white)/) { print "Match"; } else { print "Doesn't Match"; } print "\n"; }
and here the Output
sky Doesn’t Match
blood Doesn’t Match
cat Match
horse Match
life Match