Storing Data on the Server
One of the things this system must do is to store information on the server for later retrieval and manipulation. When the user applies for membership, his information must be stored in a special holding area, awaiting completion of the verification step. When the verification has been done, that information must be retrieved and moved to its permanent home in the storage location for information about the site’s verified users.
Flat Text Files for Data Storage
We can use a number of different approaches for this kind of data storage and retrieval. Perhaps the simplest approach is to use a flat text file, with one user record per line, and some sort of delimiter character separating the different pieces of information that make up each record. Consider the following subroutine:
sub write_register_queue { # invoked with an argument of a %HoH data structure, write # that data out to the $queue_file with one record per line, # and each record's fields separated by tabs. my %HoH = @_; open OUT, "> $queue_file" or die "couldn't open $queue_file for writing: $!"; while (my($username, $href) = each %HoH) { my @record = ( ); foreach my $field ($username, $href->{verify}, $href->{password}, $href->{real_name}, $href->{phone}, $href->{email}) { # squash consec. whitespace into a single space char $field =~ s{\s+}{ }g; push @record, $field; } print OUT join("\t", @record), "\n"; } close OUT; }
This should all be pretty easy Perl for you to figure out by now. We ...
Get Perl for Web Site Management now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.