#!/usr/bin/perl -w # cd /home/xiangyang/Desktop/P.stutzeri_genome/Blast_A1501 # perl /home/xiangyang/Desktop/P.stutzeri_genome/Blast_A1501/intersection.pl use strict; use Data::Dumper; use List::Compare; # use List::Compare::Functional qw(:originals :aliases); my %file31; my $path3="/home/xiangyang/Desktop/P.stutzeri_genome/Blast_A1501/split"; #"$path1/split/"; opendir DIRRR, $path3 or die $!; my @to_be_compared=(); my @dir3 = readdir DIRRR; closedir DIRRR; foreach my $file3(@dir3){ my $input="$path3/$file3"; my @file3=(); open IN,"$input" or die $!; while () { my $name=$_; $name=~s/(.+);\[//g; $name=~s/\]$//g; push (@file3,$name); } if (scalar @file3 >0) {push (@to_be_compared, \@file3)}; # print "@file3\n"; } my $lc = List::Compare->new({ lists => \@to_be_compared} ); my @intersection1 = $lc->get_intersection; # my @intersection1 = get_intersection(\@to_be_compared); print scalar(@intersection1)."\n"; print (join ",", @intersection1); print "\n"; ##################################################################################################################################### opendir DIRRR1, $path3 or die $!; my @dir31 = readdir DIRRR1; closedir DIRRR1; mkdir "$path3/MODIFY/"; foreach my $file31(@dir31){ my $inputt="$path3/$file31"; open INN,"$inputt" or die $!; while () { my $namee=$_; $namee=~s/(.+);\[//g; $namee=~s/\]$//g; $file31{$namee}=$_; } my $output_1="$path3/MODIFY/$file31.MODIFY"; open(OUTPUT_1, ">$output_1"); foreach my $iii(@intersection1){ if (exists $file31{$iii}){ my $valuee=$file31{$iii}; print OUTPUT_1 "$valuee"; } } } # print %file3;