#!/bin/perl -w open IN,"gzip -dc $ARGV[0] |"; local $/="//\n"; while(){ chomp; my ($AC, $entry_id, $goid) = ("-","-","-"); ($AC)=$_=~/\nAC ([^;]+)/; ($entry_id)=$_=~/\nDR GeneID; (\d+)/ if /\nDR GeneID;/; if(/\nDR GO; GO:\d+/){ my @go=$_=~/\nDR GO; (GO:\d+)/g ; my %hash; my @unique = grep { !$hash{$_}++ } @go; $goid=join(";",@unique); } print "$AC\t$entry_id\t$goid\n"; } close IN;