#!/usr/bin/perl use warnings; use strict; open DATA, "C:\\Users\\Jems\\Desktop\\Perl\\test\\test.txt" or die $!; use Modern::Perl; use Data::Dump qw/dump/; our %data; my $ac; while () { my @splitted= split(/=|;/); foreach (@splitted){ if (/^(.{6})\sORFNames/) { $ac = $1; chomp ($ac); next; } if (/^(.+)\s\n/) { #print "$ac $1\n"; push @{ $data{$1} }, $ac; next; #print @{$data{$ac}} if exists $data{$ac}; } if (/^(.+)\s;PF/) { push @{ $data{$1} }, $ac; next; } next;} next; } my $acn; open ACTIVATOR, "C:\\Users\\Jems\\Desktop\\Perl\\test\\Test2.txt" or die $!; open ACTIVOUT, ">C:\\Users\\jems\\Desktop\\Perl\\test\\ActivACNPF.txt" or die $!; select ACTIVOUT; while ($acn= ){ if($acn =~ m/^(......)\s\|/){ my $ab = $1; chomp ($ab); #print "$ab"; print "$acn | @{$data{$ab}}\n" if exists $data{$ab}; next; } } print STDOUT "DONE ACTIV";