I agree with your suggestion here. However, let me tell you a little about the genealogy of this bit of code, because there's another stage to come and I'd like a suggestion about how to complete this. For links I used to have something like this:

a({href=>"/cgi-bin/musing.cgi?musing_id=$musing_id"}, $musing_heading)

This worked fine for a long time. However, I would change occasionally the name of a script or move it to a different directory. For example, musing.cgi used to be called web_log.cgi. Then I'd have to go through my scripts and other places where script names were contained and change it. Last year I came up with the idea of entering the names of all of my scripts in a table in MySQL I named site_scripts. Now if I want to change the name of a script or location of a script, I change it in my site_scripts table in MySQL. I just use the same key name (e.g., musing) to retrieve it. This has worked well for me so far.

Now what I want to do is to add the particular ID for the script. For instance, for a musing I generally have musing_id as the CGI variable name. For it, I'd like to change '?musing_id=' to something less hard-coded to something like this:

a({href=>scripts->{'musing'}->{'script'} . '?' . script_ids->{'musing'}->{'id'} . '=' $musing_id}, $musing_heading)

To tighten this up more, and to reduce the interpolation you mention, I could add the ? and the = to the hash containing the id label. Of course, once I have this problem worked out, I can have a sub-routine for my hyperlinks: hyperlink('musing',$musing_id,$musing_heading)

That would be so much nicer, wouldn't it? It would be simple to set up another column in my site_scripts table in MySQL to hold the ID label. However, for some scripts I need more than one CGI variable: /cgi-bin/musing.cgi?musing_id=$musing_id&ref_id=$ref_id. That might also through off my hyperlink() idea. So, any suggestions on how I might organize multiple ID possibilities in MySQL or how to sort through them in Perl when deployed with a function?

-Spenser

That's Spenser, with an "s" like the detective.


In reply to Re^2: How's My Style Now? by Spenser
in thread How's My Style Now? by Spenser

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.