Hi, I post again my question with some changes.Part of my script is like this:
#!/usr/bin/perl -w use strict; use warnings; my $taxId = [0-9]; my $taxId1 = $ARGV[0]; my $taxId2 = $ARGV[1]; my $C = getDistance ($common_node); print $C; sub getParent { my ($taxId) = @_; my @parent_list = ""; while ($taxId = $taxId1){ my $parent = `getz "[taxonomy:$taxId1]" -f pid`; chomp $parent; $parent =~ s/PARENT ID :/ /; $taxId1 = $parent; push @parent_list, $parent; # } return @parent_list; } sub getDistance { my ($common_node) = @_; my $id; my $count; do{ $id = getParent ($taxId); $count++; }until ($id eq $common_node); return $count; }
There are some points I have to mention. First in command line I put two taxId1 and taxId2. But I also use taxId (that can be any digit and I am not sure is true or not). Second $common_node is just a number that I defined in main program(not in this post) and I want to find distance between this point and taxId1 or taxId2. In the first subroutine (get parent) I found some numbers that one of those is $common_node and just I want to count from the first number until that point ($common_node). Any response would be appreciated.
In reply to do until question by semi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |