I will have to agree with Art_XIV on this and suggest you look into some kind of database to store this amount of data for you; like it was already suggested, SDBM would work nice for a project like this.

First and foremost, I don't see you using strict anywhere. When you're messing with this many variables, especially a username and password, it's safer if you use strict; in the beginning of your program. Please refer to strict or type perldoc strict in CMD.

If you went with the SDBM route, you could check for already used usernames by using an if statement. Something like this is what I've always used (assuming the user name is used as the hash key):

foreach (keys %personalDetails) # iterate over every key/value pair st +ored in database { if (exists $personalDetails{$testUsername}) # check to see if the us +ername exists using "exist" { print "Error: This screen name is already being used.\n"; exit; } }
Using a database rather than writing to a file will make your life a lot easier. You won't have to use while (<>), checking to see if particular elements are already stored and retrieving data is a million times easier and faster.

Another thing I noticed is you're adding leading spaces when you print to the personalData file. Are you sure you didn't want to put spaces at the end of the line instead?

print TEXTWRITE " $firstname"; print TEXTWRITE ",";
Could be shortened into one line, since it's always nicer being lazy, right?  print TEXTWRITE "$firstname,";

One final thought. Since you're using CGI.pm, you can forget about printing HTML headers the old fashion way. Let CGI.pm do the work for you.  print header, start_html('This is the title of my page!'); prints all your header information for you in one line.

I hope this helps.



"Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"

sulfericacid

In reply to Re: Perl to wite and search text file by sulfericacid
in thread Perl to wite and search text file by Ragna

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.