Herself’s Webtools

Webtools for Webmasters: Scripts, HowTos, Templates, Plugins, Widgets, Tips and Useful Information

Herself’s Webtools header image 1

Change Webpage Daily

February 27th, 2007 · No Comments

I needed to update the TimesToCome Daily Horoscope page ( no longer on web ) but I didn’t want to have to do it manually. Now I can upload a week or month of new pages information and have the computer load the appropriate page for a given day by checking the system date. This script works great if you are only using straight html.

If you use Flash movies or javascript or other languages, they don’t work properly. The way to work around this is to use frames. Load your other languages and embedded code into the main frame and call the Perl script to update the secondary frame.

#!/usr/bin/perl#www.timestocome.com
#program to update a web page with new information daily.
##Name each webpage for each day you wish to appear daily_dayofyear.html.
##So the daily update for Jan 2 would be daily_2.html
#The page for Dec 15 would be daily_350.html ( don’t forget to adjust for leap years )
##put them off your top level directory in a directory#named daily.##Put this file in your cgi-bin directory with the proper permissions ( 755 )

###To use this link to#< a href=”http://www.yourdomain.com/cgi-bin/daily.pl > Page < /a >

#This link will bring up the page for today.

##############################################################
##################
#get day of year
$today = (localtime(time()))[7];

#add file extention
$tag = “html”;

#add file information
$name = “daily”;

#clean up and stick together to build file name
chomp($today);
chomp($tag);
chomp($name);
$temp = join “.”, $today, $tag;
$filename = join “_”, $name, $temp;

#open the file for reading
open(IN, “../daily/$filename”);
flock(IN, 2);

#lock the
fileseek(IN, 0, 0);

#rewind to beginning
#create the html page
print “Content-type:text/html\n\n”;
while ( ){
print ;
}

close IN;

Tags: HTML · perl · tools

0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.

You must log in to post a comment.