The Register Script

So, now that we have subroutines for reading and storing the various kinds of files we need to manipulate, we’re ready to create the CGI scripts that our users will use to register on the site. Since the reading and writing subroutines will need to be shared by both the registration script (register.cgi) and the verification script (verify.cgi), we’ll put those routines in a separate module file (Register.pm) that each script can pull in with a use statement.

Example 19-2 shows the finished Register.pm module.

Example 19-2. The finished Register.pm module

package Socalsail::Register; # a module to contain routines for accessing and manipulating the # various membership-related files on the Socalsail site. use strict; BEGIN { use Exporter; use Fcntl ':flock'; use vars qw(@ISA @EXPORT @EXPORT_OK $VERSION $queue_file $queue_file_semaphore $member_file $member_file_semaphore $htgroup_file $htgroup_semaphore $htpasswd_file); $VERSION = '0.01'; $queue_file = '/w1/s/socalsail/maint/data/pending_memberships.txt'; $queue_file_semaphore = $queue_file . '.sem'; $member_file = '/w1/s/socalsail/maint/data/members.txt'; $member_file_semaphore = $member_file . '.sem'; $htgroup_file = '/w1/s/socalsail/maint/data/.htgroup'; $htgroup_semaphore = $htgroup_file . '.sem'; $htpasswd_file = '/w1/s/socalsail/maint/data/.htpasswd'; @ISA = ('Exporter'); @EXPORT = qw( ); @EXPORT_OK = qw(read_register_queue write_register_queue read_members write_members read_htgroup write_htgroup); } ...

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.