in reply to Re: Simple iteration problem
in thread Simple iteration problem

I agree with much of this. However, i think it should be:
$seed = $tab[0];
Etbr77, here is my version (which is nearly identical to AnonMonk's):
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;
Since I really have no idea what your input file looks like, I created my own sample input file (test.txt):
3 5 6 7 2 22 222 10 9
When I run this script, I get the following output:
tab[0]=3 tab[0]=5 tab[0]=10
If this is not what you are looking for, please provide a small sample of your input, and expected output.

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
    I'd just like to add that there's really no reason to include the
    else { next; };
    part, since without it the functionality is exactly the same.
Re^3: great
by Etbr77 (Initiate) on Nov 29, 2007 at 16:53 UTC
    It works great now! Thank you all very much.