Hi
I am writing a script in perl. My question is about of part of this script. I have a subroutine that makes a problem. Everything is OK when I don't use SUB but when I use it just give me the first part of the file (just $i=0). but it seems should work as a loop. Any command appreciated.
sub edit
{
my ($list) = @_;
my @species = "";
my $pid = "";
my @tree = "";
@species = split "//", $list;
while(my $i = 0; $i < scalar @species; $i++) {
if($species[$i] =~ /RANK *: subspecies/ && $species[$i] =~ /PARENT ID * : (\d+)/){
$pid = $1;
# # print "$pid\n";
$species[$i] = `getz "[taxonomy:$pid]" -e`;
@tree = $species[$i];
return @tree;
}
}
}
I am writing a script in perl. My question is about of part of this script. I have a subroutine that makes a problem. Everything is OK when I don't use SUB but when I use it just give me the first part of the file (just $i=0). but it seems should work as a loop. Any command appreciated.
sub edit
{
my ($list) = @_;
my @species = "";
my $pid = "";
my @tree = "";
@species = split "//", $list;
while(my $i = 0; $i < scalar @species; $i++) {
if($species[$i] =~ /RANK *: subspecies/ && $species[$i] =~ /PARENT ID * : (\d+)/){
$pid = $1;
# # print "$pid\n";
$species[$i] = `getz "[taxonomy:$pid]" -e`;
@tree = $species[$i];
return @tree;
}
}
}
Comment