line 1 have some string here and Hash_key_4: Hash_value_4_identical_to_Hash_value_9 line 2 have some string here and Hash_key_5: Hash_value_5 line 3 have some string here and Hash_key_6: Hash_value_6 line 4 have some string here and Hash_key_7: Hash_value_7_identical_to_Hash_value_2 line 5 have some string here and Hash_key_1: Hash_value_1 line 6 have some string here and Hash_key_2: Hash_value_2_identical_to_Hash_value_7 line 7 have some string here and Hash_key_3: Hash_value_3 line 8 have some string here and Hash_key_8: Hash_value_8 line 9 have some string here and Hash_key_9: Hash_value_9_identical_to_Hash_value_4 line 10 have some string here and Hash_key_10: Hash_value_10 .... .... #### Hash_key_1 => Hash_value_1 Hash_key_2 => Hash_value_2_identical_to_Hash_value_7 Hash_key_3 => Hash_value_3 Hash_key_4 => Hash_value_4_is_identical_to_Hash_value_9 Hash_key_5 => Hash_value_5 Hash_key_6 => Hash_value_6 Hash_key_7 => Hash_value_7_identical_to_Hash_value_2 Hash_key_8 => Hash_value_8 Hash_key_9 => Hash_value_9_is_identical_to_Hash_value_4 Hash_key_10 => Hash_value_10 .... .... #### my %hash = (); my $filename = "input_text.txt"; open FILE,"<$filename" or die "Cannot read the file $filename: $!\n"; foreach { if (my $line =~ m/{$Hash_value{key}}/) { print "$line has $hash{$key} and value is $hash{key}\n"; } }