in reply to Re: Bit of maths between two files
in thread Bit of maths between two files

i will have a go at this suggestion, thanks

Replies are listed 'Best First'.
Re^3: Bit of maths between two files
by mawe (Hermit) on Aug 05, 2004 at 16:04 UTC
    Hi!

    Try this:
    my @file = @ARGV; my @coords; foreach $f (@file) { open (FILE, "<$f"); while (<FILE>) { my @line = split(/\s+/,$_); for my $i (0..$#line) { $coords[$i] += $line[$i]; } } close FILE; } print "@coords\n";
    mawe
      thanks for that, in addition how could i adjust this so that it sumsthe first x in file1 with first x in file2?
Re^3: Bit of maths between two files
by Anonymous Monk on Aug 05, 2004 at 15:55 UTC
    have tried the following but no success!
    $file = shift@ARGV; $file2=shift@ARGV; open (FILE, "<$file"); while (<FILE>) { @array = ( ); chomp; ( $x, $y, $z) = split (/\s+/, $_); push @array, $x; $size = @array; } open (FILE2, "<$file2"); while (<FILE2>) { ($x1, $y1, $z1) = split (/\s+/, $_); for ($i=0; $i<$size;$i++) { $sum = $x1+$array[$i]; print $sum; } #print $sum; }