Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8542259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:01:13+00:00 2026-06-11T12:01:13+00:00

I have cgi search engine for local flat database search and I would like

  • 0

I have cgi search engine for local flat database search and I would like to add option the user able to export/download the search result. is that possible with cgi?
this is the code.

     #!/usr/bin/perl
      read(STDIN, $buffer,$ENV{'CONTENT_LENGTH'});
      # Split the name-value pairs
      @pairs = split(/&/, $buffer);
      foreach $pair (@pairs) {
       ($key, $value) = split(/=/, $pair);

     $value =~ tr/+/ /;
      $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

     $formdata{$key}.= "$value";
      }
   $search = $formdata{'search'};
   open(INFO, "/test.txt");   
   @array=<INFO>;
   close (INFO);
   print "Content-type:text/html\n\n";
   print "<html>\n";
    print "<head><title>Search result</title></head>\n";
   print "<body>\n"; 
   print "<h4><font color=#990000>This is your search result!</h4>\n"; 
   $search_url = 'https://test.php';
   foreach $line (@array) {
   if ($line =~ /$search/){
   ($host,$ip)=split(/\|/,$line);
   $records= ++$counter;
   @result =($host,$ip);
   print "<font color=#7a378b><b><p>";
   print "<table border=0 cellpadding=0 cellspacing=0 style=border-collapse: collapse       
   bordercolor=#111111 width=20% bgcolor=#C0C0C0>";

   print "</tr>";
   foreach (@result) {
   @words = split ;
   print     "<tr><td width=33% bgcolor=#DCDCDC><b><font color=#000080 size=1   face=Courier New>$words[0]</font></b></td>";
  print     "<td width=36% bgcolor=#DCDCDC><b><font color=#000080 size=1 face=Courier    
  New>$words[1]</font></b></td>";
  print "</table>";
 }
 }
   }

  if ($records== 0) {
  print " Sorry! No records found\n";
   }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T12:01:14+00:00Added an answer on June 11, 2026 at 12:01 pm

    Yes. The conventional way is to output the appropriate content type header, e.g.

    Content-type: text/csv
    Content-type: text/xml
    

    and optionally to specify a “content disposition” as well. In conforming browsers, this will give the client the option to save the server’s output to a local file:

    Content-disposition: attachment;filename="myfilename.csv"
    

    (Edit to use friedo’s wise suggestion)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this CGI script, but how do I start a download in the
I am working with Perl/CGI, MySQL, Perl Template toolkit. I have a database set
In other sites I've worked on, I have been able to easily generate search
I have cgi script pulling search terms from an HTML form through CGI::Ajax .
I have this simple cgi script working just fine but I want to add
I have a web service that performs a database search. It accepts both GET
I have a task and would like to develop in my mind how i
I have a dynamic url at http://www.technicae.net/cgi-bin/type/mt-search.cgi?IncludeBlogs=2&tag=2%|tag|&limit=20 where the '|tag|' and '20' part change
I have a basic form that I would like to submit using ajax, without
I have a CGI script that prints the following on stdout: print Status: 302

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.