in reply to Re: going through an array
in thread going through an array

so initially read the first colum from here into @value
112 104.35 141.94 115 22.34 29.13 while (<IN>) { ($rub,$res) = split (/\s+/,$_); push @value, "$res\n"; }
where this first column value agrees with the third colum in the next file, replace 100.0 with 3.0
1 59 49 0.0 0 100.0 0.0 1 60 50 0.0 0 100.0 0.0 using code supplied in first post

Replies are listed 'Best First'.
Re^3: going through an array
by NetWallah (Canon) on Nov 21, 2004 at 01:50 UTC
    Your description of column counting seems to be a bit off.

    In your case, the SECOND column values (104.35, 22.34) get populated into @value. If you had wanted the first column, you would need to "push @value,$rub" . (And why are you adding the trailing "\n" ?)

    Also, in your original post, taking the index [3] from the result of the "split" gets you the FOURTH column (zero based).

    Most likely, a better understanding of perl's zero-based indexing would help fix this program.

        Earth first! (We'll rob the other planets later)

      And the trailing "\n" will cause your numeric comparison to never get a match.

        It shouldn't matter. Can you post a test case that demonstrates that it does?

        #! perl use strict; use warnings; use Test::More tests => 1; my $x = 100; my $y = 100 . "\n"; cmp_ok( $x, '==', $y, 'numeric comparison should numify SVs' );
Re^3: going through an array
by Anonymous Monk on Nov 21, 2004 at 00:34 UTC
    btw these are only segments from complete files