open (CYT, "C:/Work/ING_Occurrences_Companies/CytokineArrays.txt"); #### open (CYT, "C:/Work/ING_Occurrences_Companies/CytokineArrays.txt") or die "can't read 'C:/Work/ING_Occurrences_Companies/CytokineArrays.txt': $!\n"; #### use strict; my $cytok_file = "C:/Work/ING_Occurrences_Companies/CytokineArrays.txt"; open CYT, '<', $cytok_file or die "can't read '$cytok_file': $!\n"; #### while (){ chomp; @cytokine=split(/\t/,$_);} #### while () { chomp; my ($name, $description, $ID ) = split /\t/; $occurrences{$ID} = 0; # initial count } #### while () { chomp; my $ID = (split /\t/)[2]; $occurrences{$ID} = 0; # initial count } #### while () { chomp; $occurrences{ (split /\t/)[2] } = 0; # initial count } #### close CYT; #### close CYT or die "can't close filehandle CYT properly: $!\n"; #### open (OUT, ">C:/Work/ING_Occurrences_Companies/ING_Count.txt"); open (IN, "C:/Work/ING_Occurrences_Companies/ING.txt"); #### my $outfile = "C:/Work/ING_Occurrences_Companies/ING_Count.txt"; my $infile = "C:/Work/ING_Occurrences_Companies/ING.txt"; open OUT, '>', $outfile or die "can't write '$outfile': $!\n"; open IN, '<', $infile or die "can't read '$infile': $!\n"; #### while (){ chomp; @ING=split(/\t/,$_); $count = 0; if($ING[2] =~ /@cytokine[1]/){ $count++; print OUT "$ING[0]\t$ING[1]\t$cytokine{$ING[2]}\t$count\t\n"; }} #### my %lines; while () { chomp; my $ID = (split /\t/)[2]; $ocurrences{$ID}++; $lines{$ID} = $_; } #### foreach my $ID (sort keys %ocurrences) { print $lines{$ID}, "\t", $ocurrences{$ID}, "\n"; }