homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

Perl script question

5+ Year Member

Msg#: 4172772 posted 1:49 pm on Jul 19, 2010 (gmt 0)

A client of mine had a website developed some years ago and has a very simple CMS which is based on a simple flat file database with a text file and perl script. The client does not want to pay for a rewrite of the site (my experience is in PHP) but wants to make a simple change to the site which I cannot work out with my very limited knowledge of perl.

From what I can see, the perl script does a number of substitutions from the site template. For instance $include[filename.html] entered into the template will mimic the equivalent of an SSI command. This only works when entering a filename. I need to change the script so it also calls in a script (banner script) or url.

How do I change the $include code below to make this happen. I understand I will need to use get and call LWP::Simple; from the beginning of the script, but I'm not sure what I else I need to do.

I thought about adding another variable $geturl and edited / duplicated the $include statement to no avail.

$formTemplate=~s/$geturl\[([^\]]+)]/qx(get ""$1"")/ge;
$formTemplate=~s/\$geturl/ /g;

Extract of script where template substitions are done.

$formTemplate=~s/$include\[([^\]]+)]/qx(cat ""$1"")/ge;
$formTemplate=~s/\$include/ /g;
if ($useCart) {
$formTemplate=~s/\$addbutton/<FORM NAME=\"cart1\">$tmp<\/FORM>/g;

print ($formTemplate);



WebmasterWorld Senior Member 5+ Year Member

Msg#: 4172772 posted 4:38 pm on Jul 19, 2010 (gmt 0)

You're on the right track.

$formTemplate=~s/$geturl\[([^\]]+)]/qx(get ""$1"")/ge;


and you should be fine. qx would run it as a systemcommand, and get from LWP::Simple is a perlfunction.
It'll require complete URLs (http://host/uri), unlike SSI would. You forgot to escape the closing square brackets and I escaped the $ in the matching part just to make it clear that it's not a variable named $geturl, but it'd work without it, too.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved