#!/usr/bin/perl use strict; use warnings; use Data::Dumper; while () { next unless (/^$hash{$name}\n"; } print "\n"; } =prints: name=value pairs: id=>123 lo=>1 rb=>This is a long rb. to=>abc name=value pairs: id=>456 lo=>2 rb=>Short rb to=>def name=value pairs: id=>789 lo=>3 rb=>Medium long rb to=>ghi name=value pairs: id=>987 lo=>6 rb=>This should be a match to=>mno name=value pairs: id=>FFF lo=>7 rb=>This is a very, very, very long are-bee. to=>pqr =cut __DATA__