#!/nairvigv/bin/perl use strict; use warnings; use Data::Dumper; my $file1 = 'BBIDs.txt'; my $file2 = 'fixedincomeTransparency.out.px.derived.updates'; #reading file1 into a hash my %hash; my @fields; open (my $fh,'<',$file1) or die $!; while(my $line=<$fh>) { chomp $line; next if $line =~ /^\s*$/; $hash{$line}=1; } #print Dumper(\%hash); close $fh; open (my ($fh2),$file2) or die $!; while (my $row = <$fh2>) { chomp $row; print "$row\n"; next if $row =~ /^\s*$/; my (@fields) = split(/\|/, $row); print "$fields[0]\n "; if (exists $hash{$fields[0]}) { print "$row\n"; } } close $fh2; ~