----- Original Message -----
From: ""John W. Krahn"" <[EMAIL PROTECTED]>
Newsgroups: perl.beginners
To: "Perl Beginners" <beginners@perl.org>
Sent: Tuesday, October 10, 2006 4:43 PM
Subject: Re: saving surrounding text in substitution
Chris Charley wrote:
(I've re-writteen your entire code below.You how much simpler it could
be.)
#!/usr/bin/perl
use strict;
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";
my %id_global;
while (<ID>){
my ($id, $code, undef) = split ' ', $_, 3;
If you want simpler then:
my ($id, $code) = split;
Yes indeed. In addition, I mucked up the last while loop.
Left my thinking cap in the garage :-(
while (<TREE>){
foreach my $code (keys %id_global){
s/$code/$id_global{$code}/;
}
print;
}
$id_global{$code} = $id;
}
:-)
John
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>