Ok say file.htm had a thing called %!poll!%, and in my script I wanted to replace that with a subroutine, that looks like this.
sub poll_view { $sth = $dbh->prepare("SELECT * FROM poll WHERE status = 'active'"); $sth->execute or die $dbh->errstr; @slog = $sth->fetchrow_array; print qq~ <table align="center" width="100%" cellpadding="4" cellspacing="0"> <tr> <td class="darktext"> <font size="2"><b>$slog[1]</b></font> <table width="100%" cellpadding="2" cellspacing="2"> ~; poll_do_it("darktext"); print qq~ </table> </td> </tr> </table> ~; } sub poll_do_it { ($ab) = @_; for($i=2; $i <= 6; $i++) { if($slog[$i]) { $a = $i + 5; print "<tr><td width=\"190\" class=\"$ab\">$slog[$i]</td> <td width=\"10\" class=\"$ab\"> $slog[$a]</td>"; if($slog[$a] eq "0") { $fin = "0.00%"; $num = 0; } else { $fin = sprintf("%.2f%", ($slog[$a]/$slog[12])*100); $num = sprintf("%.0f", ($slog[$a]/$slog[12])*150); } print "<td width=\"160\"> <img src=\"images/left.gif\" width=\"2\" height=\"5\"><img +src=\"images/poll.gif\" width=\"$num\" height=\"5\"><img src=\"images +/right.gif\" width=\"2\" height=\"5\"></td> <td width=\"10\" class=\"$ab\">$fin</td></tr>"; } } }

In reply to including subroutines 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.