option to save to file vs display on browser?

I currently get stdout from a C program and print results to the browser (see attached code snippet).  I now give the user the option to press a different button if they want to write the output to a file.  How can I make (at least in Netscape) the file->save as dialog box come up, then have the output written to the selected file on their PC?  

Thanks! - BB

if ($option eq "Save as file") {
     ???
}
else {   #show to browser
 print "<CENTER><TABLE BORDER=0><TR>\n";
    while (<PLPRICE>) {
        ($col1, $col2, $col3, $col4) = split(/;/, $_, 4);
        print "</TR><TR>\n";
        if ($col2 eq "Quantity") {
            print "<TH>", $col1, "</TH>\n";
            print "<TH>", $col2, "</TH>\n";
            print "<TH>", $col3, "</TH>\n";
            print "<TH>", $col4, "</TH>\n";
        }
        elsif ($col3 eq "") {
            print "<TH ALIGN=LEFT>", $col1, "</TH>\n";
            print "<TD COLSPAN=3>", $col2, "</TD>\n";
        }
        else {
            print "<TH ALIGN=LEFT>", $col1, "</TH>\n";
            print "<TD>", $col2, "</TD>\n";
            print "<TD>", $col3, "</TD>\n";
            print "<TD>", $col4, "</TD>\n";
        }
    }
    print "</TR></TABLE></CENTER>\n";
    close PLPRICE;
}
borghardAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

bigbedCommented:
If you send an unrecognized content-type to the browser, it should prompt it to give the save-as box.
Normally a CGI will send:
Content-Type: text/html
for an HTML page.
In this case you could send:
Content-Type: application/octet-stream
and it should get the save-as box shown.
0
borghardAuthor Commented:
I had tried that and it didn't seem to work.  I now realize my (silly) mistake.  I had a left a debug print statement in just before this.  Once  comment that out, it works beautifully.  If you want to lock this question, I'd like to give you 60 points anyways.
Thanks!
0
bigbedCommented:
Thanks!
If you send an unrecognized content-type to the browser, it should prompt it to give the save-as box.
Normally a CGI will send:
Content-Type: text/html
for an HTML page.
In this case you could send:
Content-Type: application/octet-stream
and it should get the save-as box shown.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
borghardAuthor Commented:
thanks again - BB
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.