#!/usr/local/bin/perl # Dilip Barman, http://www.cs.unc.edu/Courses/wwwp-f97/members/barman # Sep 22 1997 # # dbDeleteRecord2.pl.cgi: Now that my perl project described at # www.cs.unc.edu/Courses/wwwp-f97/members/barman/perlProjectProposal.html, # is finally working (yeah!!), I'm going to implement the functionality of # deleting a record. This perl cgi-bin script is called from dbRetrieve2.pl.cgi # when a user pushes a submit button with name equal to the title to be # deleted. This program reads $title from STDIN, opens the DB in RW mode, # retrieves the record with that title, and asks for a confirmation of deletion. # If yes, the record is deleted. require "/afs/cs.unc.edu/project/courses/190-25f97/programs/perl/lib/cgi-lib.pl"; # GLOBAL VARIABLES $FALSE = 0; $TRUE = 1; # $DBFILENAME = "../musicDatabase/musicDB2"; # name of DBM database file $DBFILENAME = "/afs/cs.unc.edu/project/courses/190-25f97/members/barman/musicDatabase/musicDB2"; $ROACCESS = "0555"; # Read-Only open: RWX, so U=101, G=101, O=101 $RWACCESS = "0777"; # Read-Write open: 111 111 111 # Remember to set AFS directory permissions so system:anyuser (a web # client, for example) has write privilege to this directory -- # fs setat ../musicDatabase system:anyuser write # * * * P R O C E S S U S E R I N P U T * * * &ReadParse(*input); # Store input as attrib-value keys in variable input # Now $input[0] looks like "AlbumTitle=Delete" $_ = $input[0]; @words = split(/=/, $_); $title = $words[0]; # A bit more logic - special characters are read as hex - # "Eagle's GHs" is read as "Eagle%27s GHs" $title =~ s/%([0-9][0-9])/pack("c", hex($1)) /ge; # This is a modification of "magic" from class. # Look for % followed by 2 digits. Convert and repeat. # * * * T O P L E V E L H T M L S T U F F * * * print &PrintHeader; print "
"; print "\nArtist: $artist";
print "\n
Genre: $genre";
print "\n
Format: $format";
print "\n
Time: $time";
print "\n
Comments: $comments";
print "\n
Database record: \"$value\"";
# Put the button here to confirm
print "\n