in reply to Table Matching
use strict; use warnings; use Data::Dumper; my $file1 = $ARGV[0]; my $file2 = $ARGV[1]; my %names; open( my $fh1, '<', $file1 ) or die "Cannot open $file1: $!"; while (my $line = <$fh1>) { my @data = split(" ", $line); $names{ $data[0] }++; } close( $fh1 ); # have a look to see what is in %names print Dumper( \%names ); open( my $fh2, '<', $file2 ) or die "Cannot open $file2: $!"; while (my $line = <$fh2>) { my @data2 = split(" ", $line); my $element = $data2[4]; if ( $names{ $element } ) { print join("\t", @data2 ), "\n"; } } close( $fh2 );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Table Matching
by gghelpneeded (Novice) on Jul 18, 2015 at 00:02 UTC |