compile : perl prog.pl input.db result #! /usr/local/bin/perl -w #initialize all the variable, initialize flags to 0 and line to '' my $counter=1; my $file1="$ARGV[0]"; my $result=">".$ARGV[1]; my $site=''; my $titleline=''; my $siteflag=0; my $titleflag=0; open(INFO1,$file1) or die "Can't open $file1.\n"; #open file1 open(OUT,$result) or die "Can't open $result.\n"; #open result #the input files has a separator :\r\n in each line foreach() { if(/\s*TITLE\s*(.*)\r/){ ######## check the title $titleflag=1; $titleline=$1; } elsif(/\s*\/interaction_site=(.*)\r/){ ######## handle the title print OUT qq(References:TITLE\t "$titleline"\n); $titleflag=0; $titleline=''; ######## check the site $site=$1; $siteflag=1; } elsif(/\s*(.*)\r/ && $titleflag==1){ $titleline.=" "; # add a white space $titleline.=$1; #concatenate the title with previous line } elsif(/\s*\/channel=(.*)\r/){ if(check2($1)){ print OUT "Channel\t $1\n"; } } elsif(/\s*\/target_cell=(.*)\r/){ if(check2($1)){ print OUT "Target_cell\t $1\n"; } } elsif(/\s*\/c_end=(.*)\r/){ ######## handle interaction site $siteflag=0; $site=''; ######## check c_end if(check2($1)){ print OUT "C_end\t $1\n"; }# end if }#end elsif ####elsif(/\s*(.*)\r && $siteflag==1){ #### $site.=" "; # add a white space #### $site.=$1; #concatenatewith previous site #### print "Site $site\n"; #### } } # end foreach sub check2 { #check whether item = empty quotes if($1 =~ /" "/){ return 0;} else{ return 1;} }