Author Topic: Require perl script for random html  (Read 1199 times)

Calum

  • Global Moderator
  • Member
  • ***
  • Posts: 7,812
  • Kudos: 1000
    • Calum Carlyle's music
Require perl script for random html
« on: 26 May 2004, 03:24 »
hello all,

well i would like (and remember i know nothing about perl here) a perl script (yes, perl, that's what the server has on it, so no "php is best" please!    ) which will serve a random front page selected from a directory full of possible front pages. So for example, say i have a directory at ~/www/index.html.d/ and it has 20 html pages in it, every time the site is visited, the index page will call one of the 20 files at random.

also it would be good if i can find one which will display random text messages as part of the web page, so say i have a section of the page where i want "message of the day" or whatever to be displayed, every time the  page is called, that space on the page will contain a random phrase pulled from a list, stored as a text file, obviously with some sort of delineation between messages, or i suppose i could have a directory again with each message in its own file.

Now of course i wouldn't want anybody to write these as i am sure they have been written many times, but i thought probably somebody would know if thses scripts are out there somewhere for download off of somebody's site, and if so, whereare they?
any ideas? and thanks in advance...
visit these websites and make yourself happy forever:
It's my music! | My music on MySpace | Integrational Polytheism

flap

  • Member
  • **
  • Posts: 1,268
  • Kudos: 137
Require perl script for random html
« Reply #1 on: 27 May 2004, 01:07 »
This will pick a random *.html and a random motd* file from the current directory, replace occurrences of the term "MsgOfTheDay" throughout the html file with the contents of the motd file and then print the page. Just put it in your main directory and call it index.pl or something.

There might be a better way of doing this. I don't know much Perl.

Code: [Select]

[ May 26, 2004: Message edited by: flap ]

"While envisaging the destruction of imperialism, it is necessary to identify its head, which is none other than the United States of America." - Ernesto Che Guevara

http://counterpunch.org
http://globalresearch.ca


Calum

  • Global Moderator
  • Member
  • ***
  • Posts: 7,812
  • Kudos: 1000
    • Calum Carlyle's music
Require perl script for random html
« Reply #2 on: 24 June 2004, 03:10 »
thank you! i really appreciate it! for reference, i also asked this here:
http://voidmain.is-a-geek.net/forums/viewtopic.php?p=7088

but your is the first which explicitly allows me to replace parts of a page randomly, thanks again!
visit these websites and make yourself happy forever:
It's my music! | My music on MySpace | Integrational Polytheism