You are not clear whether this patch of html is the output from your program or snipped from your Perl script itself. And if it is from your Perl script, it is not clear how you are printing this out:

Are you using CGI for this?
Is it in a 'here doc'?
Are you using a print statement for each line?

The value $afld[3] can be printed or interpolated just fine. The only thing to be careful of is how to incorporate the double-quotes in your html and still interpolate the array value.

The problem of course is that if you want to interpolate the value in a string, the string has to be specified in a double-quotish manner. But if you just enclose it in double-quotes, the html double-quotes mess things up. There are a variety of approaches:

print qq[<a href="mailto:$afld[3]">]; or print '<a href="mailto:' . $afld[3] . '">';
...to give just two examples.

Note also: there is nothing between <a href="mailto:$afld[3]"> and the </a> tag. If this is an accurate snippet, the mailto: link is there but no link text is being displayed because you have specified nothing.

Update: If you have a managable number of these values to interpolate, this approach works fine. If you are doing more ambitious things with lots of interpolated values and other fancy programmatic stuff, check into the embedding/templating solutions that have been proposed.


In reply to Re: how to put perl variables inside html tags by dvergin
in thread how to put perl variables inside html tags 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.