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.


In reply to Re^2: Simple iteration problem by toolic
in thread Simple iteration problem by Etbr77

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.