###########################
#  gauge.pl
#     07.10.07

use strict;
use HTML::Template;

my(%t,@fld,$n);

my $template = HTML::Template->new(filename => 'index.html');
my @loop = ();

$t{htmfile} = 'pressure1.htm';

$t{flag} = 1;
open(IN,"pressure0.txt") or die "Can't open the file pressure0.txt";
while(<IN>){
    next if $. == 1;
    next if length($_) < 2;
    if ( $t{flag} == 1 ) {
        $t{flag} = 2;
        push(@{ $t{N1s} },$_);
    } elsif ($t{flag} == 2) {
        push(@{ $t{C1s} },$_);
        $t{flag} = 3;
    } elsif ($t{flag} == 3) {
        push(@{ $t{E1s} },$_);
        $t{flag} = 1;
    } 
}
close(IN);

for $n ( 0 .. $#{ $t{N1s} } ) {
    $t{N1} = $t{N1s}[$n];
    $t{c1} = $t{C1s}[$n];
    $t{e1} = $t{E1s}[$n];
    my %row = (
            N1 => $t{N1},
            C1 => $t{c1},
            E1 => $t{e1}
    );
    push(@loop, \%row);
}

$template->param(std_loop => \@loop);
open(OUT,">$t{htmfile}");
print OUT $template->output;
close(OUT);

__END__;