use strict; use warnings; my $mio; my $filename = '/Users/Pabli/Desktop/do_human_mapping.gmt'; my $match = 'DOID:2055'; unlink ("myoutputfilename3.txt"); open(my $file, '<', $filename) or die "open: $!"; while (<$file>){ my ($name,$id,@genes) = split /\t/; if ($id eq $match) { $mio= join("\n",@genes); print $mio."\n"; open my $out_file, '>>', 'myoutputfilename3.txt' or die "$!"; print $out_file $mio."\n"; # print sul file } } #### use strict; use warnings; my $mio2; my $filename = '/Users/Pabli/Desktop/do_human_mapping.gmt'; my $match = 'APOE'; unlink ("myoutputfilename4.txt"); open(my $file, '<', $filename) or die "open: $!"; while (<$file>){ my ($name,$id,@genes) = split /\t/; if (grep/^$match$/, @genes){ $mio2=$id; print $mio2."\n"; open my $out_file, '>>', 'myoutputfilename4.txt' or die "$!"; print $out_file $mio2."\n"; # print sul file } }