I am assuming you want to show this form on a browser with some values filled in. To do this, you will need to modify the stuff returned from the get($url) call (in the $html variable). There seem to be two approaches I can think of to do this.

If the form file is in your control, you can put in special tags (like $$USERID$$) and simply do a pattern match "substitution" to replace them with your values. Hence the form file will contain:

<input type=text name=userid value="$$USERID$$">

And you will use something like (untested!):

$userid="123"; $html =~ s/\$\$USERID\$\$/$userid/g;

And it becomes

<input type=text name=userid value="123">

There are HTML Template libraries that can help you do this and much much more. So try reusing those rather than coming up with your own replacement scheme if this is a sizeable project.

If the form is not in your control, you will need to parse the form (using module like HTML::Parser or HTML::TokeParser) to find the "input" tags and then switch the value parameter with ones of your own choice. There are examples in the documentation (man pages and Internet sites) that you can use.

-- termix


In reply to Re: Populating the form by termix
in thread Populating the form by peacemaker1820

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.