[thelist] CGI submission to print
Jeff Hinds
jhinds at netagency.com
Sat Jun 29 08:55:00 CDT 2002
I'm a novice at PERL/CGI.
Can someone help me get this script to print new submissions
to the index page?
http://www.sonvenezuela.com/tour/
This is not my script but I'm trying to modify it for my needs.
#!/usr/local/bin/perl
###############################################
# Link Management Utility
# by Alexander Moskalyuk
# http://moskalyuk.com/
# Please keep this info and refer to the site for additional support
###############################################
# Set the path to the file, i.e. what is the directory
# name on local server where the file is located?
$sitepath = "/home/sonvene/public_html/tour/";
# Set the phrase to search for, where to install the new link
$phrase = "<ul>"; # by default search for an unordered list and
# install a link after it
use CGI;
my $myobject = new CGI;
my $sitename = $myobject->param('sitename') || "SonVenezuela.com";
my $siteurl = $myobject->param('siteurl') || "http://www.sonvenezuela.com";
my $sitedesc = $myobject->param('sitedesc') || "Home of Salsa Music!";
my $siteappend = $sitepath.$myobject->param ('siteappend');
open (FILEIN, "<$siteappend") || die ("Wrong file $siteappend!");
while (<FILEIN>)
{
push (@thefile, $_);
}
close (FILEIN);
open (FILEOUT, ">$siteappend") || die ("Bye, bye, $siteappend!");
# this is where the HTML code for the new link gets created
# edit it depending on the formatting you use
my $text = "$phrase\n<li><b><a href="."$siteurl".">"."$sitename"."</a></b> -
"."$sitedesc"."</li>\n";
$|=1;
foreach $htmlline (@thefile)
{
$htmlline =~ s#$phrase#$text#i;
print FILEOUT $htmlline;
}
close (FILEOUT);
direct();
sub direct
{
# Direct users back to the URL
print "Content-type: text/html\n\n";
print ("<script language=\"JavaScript\">");
print ("window.location=\"http://www.sonvenezuela.com/tour\"\n\n");
print ("</script>");
}
</END>
Thanks in advance,
Jeff
More information about the thelist
mailing list