$word = shift; %sent = ( one => "This is sentence one. I wonder what the word is.", two => "This would be sentence two.", thr => "Is this sentence three. I think it is. I sure hope it is.", ); @matches = grep $sent{$_} =~ /\b$word\b/, keys %sent; print "The matching sentences are:\n"; for (@matches) { print; print " => ", $sent{$_}, "\n"; }