I'm not exactly clear what you're trying to do, but here are some general comments that I hope will point you in the right direction.

The statement: open (DAT,">$RECORD/$form{'User'}"); will overwrite a file in the directory data.db, whose name is the value input by the user1, but I don't think that's what you intended. My guess is you want to open the file data.db, then find the record corresponding to the input value.

If so, and you're trying to use a flat file, consider using fixed-size records. That way, you can open the file and seek to particular records either by searching sequentially or by saving the offsets of particular records.

But the operations you're describing (find a record, change its value, write it back) are much more easily accomplished with a relational database system. Otherwise you'll be re-creating index-sequential systems that were mostly abandoned years ago (for many reasons, inflexibility being one of the primary ones). Then your sub may simply reduce to two SQL statements: fetch the data, update the data.

If you don't have a database already, MySQL is an easy place to start. You can find many documents and examples for setting it up.

HTH

1BTW, creating files whose names come from user input is a bad practice in and of itself....


In reply to Re: How to overwrite one variable in an array? by VSarkiss
in thread How to overwrite one variable in an array? by rabi3

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.