if (/>(.*)/) { if (defined $list{$1}) { print $_ . "\n" . $hash1{$list{$1}} . "\n"; $x = 1; } else { $x = 0; } }