Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use strict ;
- use warnings ;
- use Data::Dumper ;
- my ($file2,$file1,$output) = (@ARGV,"output_comp") ;
- my (%hash,%tmp) ;
- (scalar @ARGV != 2 ? (print "Need 2 files!\n") : ()) ? exit 1 : () ;
- for (@ARGV) {
- open FH, "<$_" || die "Cannot open $_\n" ;
- while (my $line = <FH>){$line =~ s/^.+[()].+$| +?$//g ; chomp $line ; $hash{$_}{$line} = "$line"}
- close FH ;}
- open FH, ">>$output" || die "Cannot open outfile!\n" ;
- foreach my $k1 (keys %{$hash{$file1}}){
- foreach my $k2 (keys %{$hash{$file2}}){
- if ($k2 =~ m/^.+?$k1.+?$/i){ # Case Insensitive matching.
- if (!defined $tmp{"$hash{$file2}{$k2}"}){
- print FH "$hash{$file2}{$k2}\n" ;
- $tmp{"$hash{$file2}{$k2}"} = 1 ;
- }}}} close FH ;
- # End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement