#!/bin/perl -wT
use CGI ':standard';

my $name=param('name'); #name of star
my $file=param('file'); #mag, color or vel
$name=~s/\.html//g;
print "Content-type: text/plain\n\n";
print "$file data for $name\n";

#open the file in question
open(FILE,"../$file") or die "Oops\n";
my $line1=<FILE>;
while (defined($line1)) {
	@input1=split(' ',$line1);
	if ($name eq $input1[0]) {
		$line2=<FILE>;
		$line3=<FILE>;
		$line4=<FILE>;
		@input2=split(' ',$line2);
		@input3=split(' ',$line3);
		printf ("%-10s %9.6f %-8s %-8s %2d ",$input1[0],$input1[2],$input1[3]
		,$input1[4],$input1[5]);
		for ($i=0;$i<=$input1[5];$i++) {printf("%7.4f %7.4f ",$input1[6+2*$i]
			,$input1[7+$i*2])};
		print "\n";
		printf ("%-10s %9.6f %-8s %-8s %2d ",$input1[0],$input1[2],$input1[3]
		,$input1[4],$input1[5]);
		for ($i=1;$i<=$input1[5];$i++) {printf("%7.4f %7.4f ",$input2[4+2*$i]
			,$input2[5+$i*2])};
		print "\n";
		printf ("%-10s %9.6f %-8s %-8s %2d ",$input1[0],$input1[2],$input1[3]
		,$input1[4],$input1[5]);
		for ($i=6;$i<=19;$i++) {printf("%7.4f ",$input3[$i])};
		print "\n";
		print "$line4";
		print "\n";
	} #end of the if
	else {
		$line2=<FILE>;
		$line3=<FILE>;
		$line4=<FILE>;
	}
	$line1=<FILE>;
}