#!/usr/bin/perl

# There is a lot of junk in here, since this was cut out of a script
# which did more.

# Usage is: getfilename setWhatever.def 4
# and it will tell you the path to problem 4 in setWhatever.def
# In giving the name of the problem set, the initial "set" and
# the ending ".def" are optional.

$td = "./";
$sd = $td;

$infile = $ARGV[0];
$probnum = $ARGV[1];

sub getfilename {
	my($setname, $n) = @_;
	$cnt=0;
	open(SDF, "$sd$setname.def") or die "Cannot open $sd$setname.def";
	while(<SDF> !~ /problemlist/i) { ; }	
	while($cnt<$n) {
		if(!($l=<SDF>)) {
			die "Problem number $n not in $setname";
		}
		chomp($l);
		$l =~ s/\s*,.*//;
		$l =~ s/\#.*//;
		if($l =~ /\S/) {
			$cnt++;
			$holdme=$l;
		}
	}
	close(SDF);
	return $holdme;
}

$infile =~ s/^set//;
$infile =~ s/.def$//;
$infile = "set$infile";

$fn = getfilename($infile, $probnum);

print "$fn, 1\n";

