Hi,

I'm trying to get this program to work and it works up until the last two lines 
(substitution) which gives a syntax error...any idea what might be the problem?

thanks,

kathryn


#!/usr/bin/perl -w
use warnings;

use Bio::Seq;
use Bio::SeqIO;

#initialize id and fasta files
my $codefile = $ARGV[0];
my $treefile = $ARGV[1];

#open alignment list and create a global hash of tree codes with species name 
as 
#open gi id file and assign file handle
open(ID,$codefile)|| die "can't open id file: $!\n";
#initialize hash
my(@ID);
my %id_global;
my $id;
while (<ID>){
  #split on spaces
  my @ID = split(/\s+/);
  #print "ID->".$ID[0]."<-\n"."Code->".$ID[1]."<-\n";
  #get rid of carriage returns
  chomp;
  #define id as the code number
  my $id = $ID[1];
  #print "ID->".$id."<-\n";
  #create a global hash with code number as key and species name as value
  $id_global{$id}= $ID[0]; 
  #print $id."VALUE->".$id_global{$id}."<-\n";
}


#test that keys loaded to global hash with correct value
#foreach my $key (keys %id_global){
#print "KEY->".$key."<-->VALUE->".$id_global{$key}."<-\n";
#}


#open treefile and while through it, substituting species name value when key 
found in file.
open (TREE,$treefile)|| die "can't open tree file: $\n";
while (<TREE>){
   foreach my $code (keys %id_global){
   #print "CODE->".$code."<-VALUE->".$id_global{$code}."\n";
   $line = $_;
   #if ($line =~ m/(.*)$code([\D])/) {print "MATCH"." 
".$code."VALUE->".$id_global{$code}."<-\n";}             
   #else {print "NO MATCH"." ".$code."<-\n";} #works,matches all values w/right 
val
   $line=~ s/(.*)$code([/D])/$1$id_global{$code}$2/;
   print $line;
   }
}




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to