There are a couple of additional things you might do to improve the readability and maintainability of your code.

One Perlism that comes in hugely handy when you're generating HTML is the alternate string-quoting form. For example:my $html = qq{<font face="Arial, Helvetica, sans-serif" size="2" color="red">}; Note that you no longer have to escape the doublequotes, because qq{} lets you define alternate delimiters. I chose curly braces in this case because they're rare in HTML and minimize the amount of escaping you have to do, but other paired parenthetical characters work too, as do arbitrary non-parenthetical characters such as these:my $html = qq*<font face="Arial, Helvetica, sans-serif" size="2" color="red">*; (though I must admit I find that using asterisks as a delimiter is not so easy to read).

qq{}, like double quotes, performs variable interpolation; q{}, like single quotes, does not. There's also qx{}, which is equivalent to backticks, and qr{} for constructing regexes. See the section "Quote and Quote-Like Operators" in perldoc perlop for more info.

Secondly, you might want to factor out the HTML formatting, which seems to be the same for every message, into a subroutine or a constant. For example:

sub _format_error { return qq{<font face="Arial, Helvetica, sans-serif" size="2" color=" +red">$_[0]</font>}; } my $login_blocked = format_error('Login Blocked please wait 3 minutes +and try again'); # ...etc...
That way you only have to change things in one place if you someday want to alter the HTML formatting. It also makes the list of messages clearer to someone reading your code because they don't have to figure out what's the actual text and what's part of the HTML formatting.

Good luck!

        $perlmonks{seattlejohn} = 'John Clyman';


In reply to Re: Returing Multiple Items and possibly using an object by seattlejohn
in thread Returing Multiple Items and possibly using an object by Angel

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.