It sounds like you have a CGI script and you want to have it generate a link such that, when a user clicks on that link, a specific subroutine in your CGI gets called.

I guess the answer is a little bit "yes" and little bit "no". The biggest reason it is "no" is because each click from the user will rerun your CGI script from the beginning in a different process.

But you can make a link that will call your same CGI script with enough information for it to reconstruct the needed context and then call a subroutine. There are lots of ways of doing that and the details of that part (having the link specify the subroutine) are tiny compared to the part you didn't ask about (getting the new instance of your CGI script to reconstruct the needed context), so I think going into more details on the former would mostly be confusing, unfortunately.

If this is what you are talking about, then you should probably find a good tutorial on CGI and Perl and maybe eventually check out something like CGI::Application.

                - tye

In reply to Re: <a href> tag and subroutines (CGI) by tye
in thread <a href> tag and subroutines by atnonis

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.