I have an object. It does validation and data storage acting as a wrapper with a database. When you try to do an update if it is good it returns 1 and when it fails it returns undef. Thus the program calling it can check to see if it worked or not.

I was told here previously to keep my HTML and my modules as seperate as possible. So when an error occurs two object vars are set and hold the type of error and the string the user should see and gived details on the error. Like input too long, needs to be unique, not an e-mail address using Email::Valid, ect.

So I made a program that calls the object and gets the errors when they occur. So far so good and all works fine ( after much tuning ) but then I try to do a simple substitution into an HTML string that looks like this:
my $error_html = "<font face=\"Arial, Helvetica, sans-serif\" size=\"2\" color=\"red\" +>error<\/font>";
so I tried this:
my $error_string = $error_html; $error_string =~ s/error/$user->get_error_string/; $template->param( user_name_error_string => $error_string );
And I get this:
User=HASH(0x91e14)->get_error_string

I tried quotes I have no clue how to get the string out short of pushing it to another var and then doing the substitution. Is there a way to do this without using another var?

In reply to Substituting method from 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.