semi has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: do until question
by Corion (Patriarch) on Sep 08, 2011 at 14:45 UTC | |
|
Re: do until question
by BrowserUk (Patriarch) on Sep 08, 2011 at 14:51 UTC | |
by afoken (Chancellor) on Sep 08, 2011 at 19:00 UTC | |
by BrowserUk (Patriarch) on Sep 08, 2011 at 19:23 UTC | |
by AnomalousMonk (Archbishop) on Sep 09, 2011 at 00:17 UTC | |
by BrowserUk (Patriarch) on Sep 09, 2011 at 00:28 UTC | |
|
Re: do until question
by semi (Initiate) on Sep 09, 2011 at 08:07 UTC | |
by Anonymous Monk on Sep 10, 2011 at 06:24 UTC |