<& /htmlheader, title => 'MPC Observation Search' &>

% if ($observations) {
<div style="margin-left: 20px">
<table border=1 cellpadding=10 cellspacing=0><tr><td>
%   if (!@res) {
<h3>No matches found.</h3>
%   }
%   else {
<b>Matching designations:</b><p>
%       foreach my $r (@res) {
% my ($mops_desig, $desig) = $r =~ /(\w+)\s+(\S+)/;
<% qq{<a href="/submitted_details.html?desig=$mops_desig">$mops_desig</a> $desig} %><br>
%       } # for
</td></tr></table>
</div>
%   } # if !@res
<p>
<hr>
% } # if obs
<h2>MPC Observation Search</h2>
<p>
<form action="" method="POST">
Paste your MPC observations below:</p>
<textarea name="observations" rows="20" cols="80">
<% $observations %>
</textarea>
<p>
<input type="submit" value="Search">
</form>
<& /htmlfooter &>

<%args>
$observations => ''
</%args>

<%init>
use FileHandle;
use File::Temp;
my @res;
my $obstmp;
my $cmd = 'no';

# Write obs to temp file.
if ($observations) {
    $obstmp = new File::Temp(dir => '/tmp', TEMPLATE => 'lmpcXXXXXX', UNLINK => 1);
    print $obstmp $observations;
    $obstmp->close;

    # Crank obs through searcher.
    my $f = $obstmp->filename;
    $cmd = "lookup_sub --instance=psmops_export --multi < $f";
    (@res) = `$cmd`;
}
</%init>
