O'Reilly logo

Perl for Web Site Management by John Callender

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

An MLDBM-Using Registration Script

Once we have downloaded and installed the MLDBM and Storable modules, we can take a look at Example 20-2, which is register.cgi rewritten as register2.cgi to work with the MLDBM , GDBM_File and Storable modules to store the member data.

Example 20-2. The revised register2.cgi script

#!/usr/bin/perl -Tw # register2.cgi - sign up for membership at the Socalsail site use strict; use CGI qw(:standard); use Fcntl qw(:flock); use GDBM_File; use MLDBM qw(GDBM_File Storable); $ENV{PATH} = ''; my $notify_email = 'email@example.com'; my $sendmail = '/usr/lib/sendmail'; my $queue_file = '/w1/s/socalsail/maint/data/pending_memberships.gdbm'; my $queue_file_semaphore = $queue_file . '.sem'; my $member_file = '/w1/s/socalsail/maint/data/members.gdbm'; my $member_file_semaphore = $member_file . '.sem'; use lib '/home/jbc/lib'; use Socalsail::Make_page; my $action = param('action'); my $content = ''; unless ($action) { # show the initial sign-up form my $form = make_form( ); $content = <<"EOF"; <H2 ALIGN="center">Sign up for membership</H2> <P>You may use this form to sign up for your free Socalsail membership. Members are able to post messages in the site's discussion forums.</P> $form EOF } elsif ($action eq 'Submit Membership Application') { # first, get an exclusive lock on the queue semaphore file. open QUEUE_LOCK, "> $queue_file_semaphore" or die "can't open $queue_file_semaphore for writing: $!"; flock QUEUE_LOCK, LOCK_EX or die "can't get exclusive lock ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required