ahref.com > Guides >
Technology
Building a Site Submission Program, Continued
Preliminaries
Lines 1-6 of the program indicate the location of the perl binary on our system and explain the copyright status of the program. The path to Perl is usually /usr/local/bin/perl or /user/bin/perl. Check with your server administrator if you're not sure.
1 #!/usr/local/bin/perl -w
2 # Copyright Edward Piou, piou@ahref.com. Originally written for use
3 # on Anchor [ahref.com], 5/20/1998. Permission granted to use
4 # this code, in current or altered form, for private or commercial use
5 # provided these comments are preserved, and any changes to the code are
6 # noted in comments.
Lines 8-11 import the necessary Perl modules: CGI.pm (for handling the CGI input) and several LWP and HTTP modules (for dealing with HTTP requests). All of these modules are available at CPAN. Line 13 disables output buffering.
8 use CGI;
9 use LWP::UserAgent;
10 use HTTP::Request;
11 use HTTP::Status;
12
13 $| = 1;
Line 15 creates a new CGI object. Line 16 lets the user's browser know that the response page is an HTML document. Lines 17 and 18 use the CGI object to import the information from the form into variables in the program.
15 $cgi = new CGI;
16 print $cgi->header;
17 $input_url = $cgi->param('input_url');
18 $input_email = $cgi->param('input_email');
Lines 20-22 define several variables containing information unique to our site. This is information you should change if you copy the program. $our_ip is the IP address of the machine running the site submitter. It needs to be defined because one of the search engines (Hotbot) requires an IP address for submissions. Use your own IP address, rather than a user's IP address, so that if there is a problem with the program, Hotbot will know it is our machine that is causing problems. Lines 21 and 22 define our header and footer files. These files include the HTML code which goes before and after the dynamic output of the program.
20 my $our_ip = "205.177.109.84";
21 my $HEADER = "/documentpath/header.inc";
22 my $FOOTER = "/documentpath/footer.inc";
|