#!/usr/bin/perl -w print ("Enter the word to search >> "); chomp ($word = ); $/=undef; $_=<>; my @arr = split /()/; shift @arr; # 1st element stuff before , so shift away my %hash = @arr; print map {($_, $hash{$_})} grep { $hash{$_} =~ $word } keys %hash;