#!/usr/bin/env perl
# Integrate column data by trapezoid rule
# Rok Zitko, zitko@theorie.physik.uni-goettingen.de, Feb, Oct, Nov 2008
# $Id$

use warnings;

my $xprev = 0;
my $yprev = 0;
my $sum = 0;

while (<>) {
  chomp;
  next if /^#/; # skip comments
  ($x,$y) = split(' ', $_, 2);
  
  if ($. != 1) {
    $sum += ($x-$xprev) * ($y + $yprev)/2.0;
  }
  
  $xprev = $x;
  $yprev = $y;
}

print "$sum\n";
