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:
# sample of href from CGI.pm use strict; use diagnostics; use CGI qw(:standard); my $id = CGI::escape(param('id')); print a({-href=>"removecard?card_id=$id"}, "Remove");

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 reply to Re: Creating a link in mason by davidov0009
in thread Creating a link in mason by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.