Don't ask to ask, just ask | |
PerlMonks |
Re: Creating a link in masonby davidov0009 (Scribe) |
on Mar 22, 2007 at 04:02 UTC ( [id://605953]=note: print w/replies, xml ) | Need Help?? |
One suggestion I can think of that might make this HTML easier to create is to use CGI.pm and its href function like so:
Here we loaded the CGI module with standard HTML functions and then assigned the variable $id to the posted variable for the id of the card the person wants to retrieve. (This would be sent to your script by a form or a query string and retrieved through the param() function) Then we make sure the id will not create a malformed URL by using the CGI::escape() function to convert any characters to their hexadecimal equivalents. Once this is done we are ready to create the HTML itself. This is done by printing out the return value from the a function, which creates the same HTML as an tag would. The link attributes are sent inside curly braces {} and are defined by the '-href' attribute. The value for the link is enclosed in double quotes ("") so that the $id variable will be interpolated by PERL and create the link to the card. The last part of the a() function is the text displayed for the link on the page. A more complete version of this script would need to create the starting and ending HTML and the neccessary header. For a good general reference on CGI.pm I would suggest the modules manual page at CPAN: http://search.cpan.org/~lds/CGI.pm-3.27/CGI.pm
In Section
Seekers of Perl Wisdom
|
|