http://www.perlmonks.org?node_id=630109

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

I'd like to think that this is a simple question, but I've searched many places and am having trouble. I'd like to combine HTML::Template (great tutorials on this btw!) with something like the "node" feature you have on PerlMonks - so that my index.pl looks like:

www.domainname.com/index.pl?id=number

How do I go about this? Can I do it without MySQL? Idealistically i would be able to type in a number and it would find that information from my database (text files), and display a page that combines my HTML::Template by using the ID tag to parse for the rest of variables on the same line in the text files.

Thanks soooo much!!!!

Replies are listed 'Best First'.
Re: Implement index.pl?something
by ikegami (Patriarch) on Aug 01, 2007 at 16:35 UTC
    Assuming index.pl is a CGI script, use CGI's param method to extract URI parameters. Then you can do whatever you want with it, including passing it as a parameter to SQL queries.
Re: Implement my own nodes
by jZed (Prior) on Aug 01, 2007 at 16:46 UTC
    There are many ways to implement this. It is usually done by having an application framework (like Catalyst or CGI::Application) to Control the flow, a database (like Pg or MySQL or SQLite) as the Model to store data and a templating system like the one you're already using to display the View. You can Control the flow yourself just by checking the querystring and using it to determine which part of the model to consult and which template to display. You can use text files as the Model though databases already cover some of the gotchas you need to watch out for. So, yes you can do it more or less as you described.