use strict; use warnings; use feature qw/ say /; my %hash_name = ( "one" => 1, "two" => 2, "three" => 3, "four" => 4 ); while ( my $line = ) { chomp $line; say "Line $. : $hash_name{$_}" for grep { $line =~ /$_/ } sort keys %hash_name; } __DATA__ This one has it. This doesn't. This one has two. Nothing here. Three times lucky. Can we get a foursome for tennis? Blerghh. #### Line 1 : 1 Line 3 : 1 Line 3 : 2 Line 6 : 4