Hi there!
I am working on a library of functions that print
different HTML tags, given non-HTML text arguments.
(Some might think it's kind of stupid since there are already modules that do this, but it's turing out to be a great way for me to get really down and dirty with the Perl -- and I am digging it!)
It's working great so far!
Except that I think I hit upon a hitch and may have discovered what is either a shortcoming (probably intentional) in Perl or in my implementation (more likely the case.)
The issue revolves around passing a subroutine as part of a text string that forms the argument of a call to another subroutine.
Here's the code:
# The main subroutine in question
sub MessagePrinter
{
my(@logmessages) = @_;
ULStart();
foreach $message (@logmessages)
{
LI();
Strong($message);
}
ULEnd();
}
############################################
# Suppporting subroutines
sub ULStart
{
print "<UL>";
}
sub LI
{
my($inputValue) = @_;
print "<LI>$inputValue\n";
}
sub ULEnd
{
print "</UL>";
}
######################################
As stated above, everything works great (unless I have inadvertantly introduced some typos.)
But... I would be happier if I could issue the call to
LI() in the sixth line of PrintMessage(%
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.