

system("ls c*.txt > temp_list");

open(fp0,"temp_list") || die;

while($line0=<fp0>) {
	chomp($line0);
	open(fp1,"$line0") || die;

	$file=$line0;
	do {
		$line1=<fp1> || die;
	} until ($line1 =~ /OBJECT NAME:\s+(.+)/);
	$object=$1;
	$object=~tr/A-Z/a-z/;
	
	if ($object =~ /vesta/) {
		$obj_file="vesta";
	} elsif ($object =~ /pallas/) {
		$obj_file="pallas";
	} elsif ($object =~ /peg/) {
		$obj_file="betPeg";
	} elsif ($object =~ /boo/) {
		$obj_file="aphBoo";
	} elsif ($object =~ /oph/) {
		$obj_file="delOph";
	} elsif ($object =~ /aql/) {
		$obj_file="gamAql";
	} elsif ($object =~ /uma/) {
		$obj_file="muUma";
	} else {
		print "Don't recognise object.\n";
		die;
	}

	do {
		$line1=<fp1> || die;
	} until ($line1 =~ /FWHM:\s+(.+) pixels/);
	$fwhm=1.0*$1;


	print "$file	$fwhm	$obj_file\n";
	close(fp1);
}

close(fp0);

print "Read all c*.txt files OK.\n";

system("rm temp_list");
