I'm trying to create some HTML with Perl. The print stament has a variable immediately before some text and I read that in these cases, you should surround the variable name with brackets. Here's the code I'm using:

my $link = "<a href=\"" . &getQueryString('title') . "\">"; print "<th>${link}Title</a></th>\n";

No matter how I think about this, I can't see how using "&lt;th&gt;$linkTitle&lt;/a&gt; would be good. However, when I run this using strict and with the -w option, Perl spits out the following warning:

Ambiguous use of ${link} resolved to $link at movies.pl line 165.

I wish I could find where I read I could surround variables with brackets, but I can't. Is this valid? If so, then what's it called. Searching the web for "${" isn't proving too fruitful.

Note: After previewing the message it seems odd that I'm even splitting this into two lines. I repeat these lines with some slight modifications a few times and keeping everything in two lines keeps the code readable for me.

Thank you.


In reply to Printing Scalars Next to Text by svsingh

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.