in reply to Re^4: Compare three columns of one file with three columns of another file in perl
in thread Compare three columns of one file with three columns of another file in perl
Hi Thanks.Below is the code i tried but it does not print anything to the STDOUT.
#!usr/bin/perl use strict; use warnings; my ($infile1,$infile2) = @ARGV; open (IFILE1, "<", $infile1) || die "Cannot open $infile1 +:$!\n"; open (IFILE2, "<", $infile2) || die "Cannot open $infile2:$!\n"; my @array1; my %hash1; my $str; while (<IFILE1>) { @array1 = split (" ", $_); $str = $array1[0]."\t".$array1[1]."\t".$array1[2]; $hash1{$str} = 1; } close IFILE1; my @array2; my $string; while (<IFILE2>) { @array2 = split (" ", $_); $string = $array2[0]."\t".$array2[3]."\t".$array2[4]; #print "$string\n"; if (exists($hash1{$string})) { print "$string\n"; } } close IFILE2;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Compare three columns of one file with three columns of another file in perl
by anonym (Acolyte) on May 26, 2015 at 05:04 UTC | |
by aaron_baugher (Curate) on May 26, 2015 at 17:19 UTC | |
by anonym (Acolyte) on May 27, 2015 at 16:28 UTC |