It will be very difficult to complete the code without seeing it in its current form. However, I can offer hints.

If you read the HTML or XHTML documentation it will make clear that a form field can have an initial value set. If you are using a JavaScript library like jQuery or YUI your JavaScript library has a way to set these through the DOM, or you can do it with JavaScript directly. You can also have your Perl code dynamically write the HTML with the values already set. Some modules, such as CGI have ways to do that, as do the frameworks and toolkits for web work.

As for opening and reading a file, there's open and then many ways to read. The readline ( '<>' ) is a good way to read a file. One might also use a structured file via XML like with the XML::Simple or XML::Twig modules; via CSV; via JSON, YAML, or INI, or using dbm.

One could also use a database via the DBI or a similar module (DBI). You could then use a database backend like SQLite, DBD::mysql, DBD::Pg. or many others (DBD). There are database-like interfaces between the DBI and files like DBD::CSV or DBD::RAM if you want, but a real database may be better in the long run.


In reply to Re: Read/write file in CGI Perl by mr_mischief
in thread Read/write file in CGI Perl by sauravrout

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.