coldy has asked for the wisdom of the Perl Monks concerning the following question:
gives a file with start and end positions:my @probs =(0,0.1,0.53,0.51,0.59,0.67,0.2,0.04,0.05,0.56,0.89,0.75);
Ive tried using a loop, and I can get the sequence of positions using,2 5 9 11
I was happy with that and just filter it again for the first and last number on each line.my $positions = undef; my @segment=(); foreach (0..$#probs){ if ($probs[$_]>0.5 && $probs[$_+1]>0.5){ $positions = $positions.','.$_; } else {push @segment, $positions if ($positions); $positions = undef} }
any ideas on a better way to do this?
Thanks again!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: printing array positions that match a condition
by graff (Chancellor) on Apr 22, 2009 at 05:56 UTC | |
|
Re: printing array positions that match a condition
by NetWallah (Canon) on Apr 22, 2009 at 06:27 UTC | |
by johngg (Canon) on Apr 23, 2009 at 19:54 UTC | |
|
Re: printing array positions that match a condition
by moritz (Cardinal) on Apr 22, 2009 at 06:13 UTC | |
|
Re: printing array positions that match a condition
by przemo (Scribe) on Apr 22, 2009 at 10:12 UTC |