Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Create Easily Modifiable Html Templates For Use In Your Perl Cgis
shiv
post Mar 21 2006, 12:15 AM
Post #1


Member [ Level 2 ]
Group Icon

Group: Members
Posts: 53
Joined: 20-March 06
Member No.: 12,139





QUOTE
Hate having to place all the print statements in your program and having to escape all those quotes?

Would you like to give the ability for people who don't know how to program in perl to customize the output of your cgis?

Templates are the answer. Here's how it works. Take any html file and anywhere you place in(variable), it gets replaced with $in{'variable'}. For example, if you have $in{'name'} = 'bob' and an html file that has:
Name: in(name)

The output would look like:
Name: shiv


QUOTE
Usage (Step 1):

Use this code to call the subroutine. Replace [page] with either a relative or full path to the html template. Example: &PageOut("t_index.htm"); where 't_index.htm' is your template file. Any line that has in(variable) will be replaced with $in{'variable'}


CODE
&PageOut("[page]");



Code (Step 2):

Add the following code somewhere within your script.


CODE
sub PageOut{
local($file) = @_;
open(OUT,"$file")||print "$!: $file<br>";
while(<OUT>){
$_ =~ s/in\((\w+)\)/$in{$1}/g;
print;
}
close OUT;
}




njoy!

shiv
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Converting PSD To HTML(9)
  2. Converting HTML over to XHTML(13)
  3. What You Need Before You Can Create A Text-based Game..(5)
  4. Can You Create A Folder Name "con"(17)
  5. How To Create A Good Forum(28)
  6. Create An Ftp Server On Your Pc With Serv-u(1)
  7. Help Me Create A Text-based, Turn-based Game(9)
  8. How To: Display A Members/user List.(3)
  9. Joomla Template Kit Extension For Nvu/composer(2)
  10. Indentation In Html(4)
  11. How Do You Create A Vista?(21)
  12. How To Create Your Own Proxy Site (free And Easy)(13)
  13. How To: Create PDF With Php(18)
  14. How Do I Create Static Routes In Windows Xp?(11)
  15. Create An Animation With Powerpoint(1)
  1. Web Editor(0)
  2. The Cloning Issue(43)
  3. How Do I Create A Good Fire Animation Using Flash ?(13)
  4. Create Your Own Shout Box(13)
  5. Increase Your Knowledge Of Html Language(11)
  6. Help Needed To Create Login Script With Perl/cgi(21)
  7. Style P And H? Html Tags(2)
  8. Create A Site Without Cms But Just Dreamweaver?(6)
  9. Yaml - (x)html/css Framework(2)
  10. Easiest Free Forum To Create Custom Skin For?(2)
  11. New Browser Based Game, Create Or Conquer(4)
  12. Basic Tips and Tricks in HTML(15)
  13. Perl Vs Php(13)
  14. Create Dynamic Gui ?(7)
  15. Free Gaming Clan Templates(17)


 



- Lo-Fi Version Time is now: 5th September 2008 - 10:05 AM