Please help me bcoz its urgent. My files look like this:-sdiff diff gvimdiff etc but no success
File 1:- Harry 21 Jeff 45 Rob 78 Mett 34 Ann 17 Gilli 39 DOn 98 Ben 15 Harry 54 Rose 46 Ness 65 File 2:- 2133 32 45 45 CC Old Harry (D) (28%) 21 + -1 Rob (D) (31%) 78 + -1 Met +t (D) (14%) 34 + -1 5789 78 66 32 DD Young Gilli (D) (10%) 39 + -1 Don (D) (66%) 98 + -1 M +ett (D) (23%) 15 + +1 9027 56 77 29 GG Old Harry (D) (10%) 54 + -1 Rose (D) (%) 46 + -1 Ness + (D) (67%) 65 + 1
I am new to scripting so donno how to approach the problem. I would be obliged to get help from Monks Bravo ... Here is my code but not getting the output yet :(I have to get my results like this:- If suppose Harry, Rob and Met are present 2133 32 45 45 CC Old Harry (D) (28%) 21 + -1 Rob (D) (31%) 78 + -1 Met +t (D) (14%) 34 + -1 3 3 since all the are matching If only Gilli and Don are present in File 1 then 5789 78 66 32 DD Young Gilli (D) (10%) 39 + -1 Don (D) (66%) 98 + -1 + 2 2 since only 2 are matching 9027 56 77 29 GG Old Harry (D) (10%) 54 + -1 1 Since only 1 is matching with File 1
#!/usr/bin/perl -w open(FH, "<File1.txt") || die "Cannot open file"; %href; while( FH> ) { chomp($_); $href{$1} = $2 if $_ =~ /(\S+)\s+(\S+)/; } while (my ($key, $value) = each(%href)) { #print $key. ", ". $value."\n"; } close FH; open(FD, "<File2.txt") || die "Cannot open file"; while(<FD>) { chomp; next unless ( s{ \s+(\w+)\s+\([A-Z]\)\s+\(\d*%\)\s+\d\s+\+ +\s[+-]?\d+}{}xms and exists( $href{$1} )); my $name = $1; print "$name\t\t$href{$name}\n"; #@_=split('\t',$_); }
In reply to File Intersection problem by ashnator
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |