in reply to Re: Simple iteration problem
in thread Simple iteration problem
Etbr77, here is my version (which is nearly identical to AnonMonk's):$seed = $tab[0];
Since I really have no idea what your input file looks like, I created my own sample input file (test.txt):use warnings; use strict; open TAB, '<', 'test.txt' or die "Can not open file: $!"; my $seed = 1.04; while (<TAB>) { chomp; my @tab = split / /; my $diff = $tab[0] - $seed; if ($diff >= 0.1) { print "tab[0]=$tab[0]\n"; $seed = $tab[0]; } } close TAB;
When I run this script, I get the following output:3 5 6 7 2 22 222 10 9
If this is not what you are looking for, please provide a small sample of your input, and expected output.tab[0]=3 tab[0]=5 tab[0]=10
Update: Removed unnecessary else, thanks to Eimi Metamorphoumai.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Simple iteration problem
by Eimi Metamorphoumai (Deacon) on Nov 29, 2007 at 17:08 UTC | |
|
Re^3: great
by Etbr77 (Initiate) on Nov 29, 2007 at 16:53 UTC |