#! /usr/local/bin/perl # Author: Peter Loeb - June 1999 print "Content-type: text/html\n\n"; print "Bookmark\n"; print "

Bookmark

\n"; # determine whether post or get # in either case obtain form data into frmdta if ($ENV{'REQUEST_METHOD'} =~ /post/i) { read(STDIN, $frmdta, $ENV{'CONTENT_LENGTH'}); } else { $frmdta = $ENV{'QUERY_STRING'}; } # an ampersand (&) separates each name=value pair @formdata = split(/&/, $frmdta); # process the name=value pairs foreach $pair (@formdata) { # split name=value into name and value ($name, $value) = split(/=/, $pair); # get rid of various extraneous web stuff, including SSI $value =~ s/\+/ /g; $name =~ s/\+/ /g; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $name =~ s///g; $value =~ s///g; # the NamVal hash allows us to look up values by name if ($value ne "") { $NamVal{$name} = $value; } } # check for required fields # if any field is missing, include a line to inform the user $palflag = 0; # assume all fields entered if ($NamVal{'Author'} eq "") { print "Author not filled in; please fill in and re-submit.

\n"; $palflag = 1; # mark that a field is blank } if ($NamVal{'Title'} eq "") { print "Title not filled in; please fill in and re-submit.

\n"; $palflag = 1; # mark that a field is blank } if ($NamVal{'NumPages'} eq "") { print "Number of Pages not filled in; please fill in and re-submit.

\n"; $palflag = 1; # mark that a field is blank } # if any field is blank, end-off and get out if ($palflag eq 1) { print " \n"; exit 0; } # set up the fract and perc arrays $fract[0] = '1/10'; $perc[0] = 10; $fract[1] = '1/9 '; $perc[1] = 11; $fract[2] = '1/8 '; $perc[2] = 12; $fract[3] = '1/7 '; $perc[3] = 14; $fract[4] = '1/6 '; $perc[4] = 16; $fract[5] = '1/5 '; $perc[5] = 20; $fract[6] = '2/9 '; $perc[6] = 22; $fract[7] = '1/4 '; $perc[7] = 25; $fract[8] = '2/7 '; $perc[8] = 28; $fract[9] = '3/10'; $perc[9] = 30; $fract[10] = '1/3 '; $perc[10] = 33; $fract[11] = '3/8 '; $perc[11] = 37; $fract[12] = '2/5 '; $perc[12] = 40; $fract[13] = '3/7 '; $perc[13] = 42; $fract[14] = '4/9 '; $perc[14] = 44; $fract[15] = '1/2 '; $perc[15] = 50; $fract[16] = '5/9 '; $perc[16] = 55; $fract[17] = '4/7 '; $perc[17] = 57; $fract[18] = '3/5 '; $perc[18] = 60; $fract[19] = '5/8 '; $perc[19] = 62; $fract[20] = '2/3 '; $perc[20] = 66; $fract[21] = '7/10'; $perc[21] = 70; $fract[22] = '5/7 '; $perc[22] = 71; $fract[23] = '3/4 '; $perc[23] = 75; $fract[24] = '7/9 '; $perc[24] = 77; $fract[25] = '4/5 '; $perc[25] = 80; $fract[26] = '5/6 '; $perc[26] = 83; $fract[27] = '6/7 '; $perc[27] = 85; $fract[28] = '7/8 '; $perc[28] = 87; $fract[29] = '8/9 '; $perc[29] = 88; $fract[30] = '9/10'; $perc[30] = 90; # number of array elements in both fract and perc $anum = 31; # finally, do the bookmark print "

\n"; # center the headings print "$NamVal{'Title'}
\n"; # print the title print "$NamVal{'Author'}
\n"; # print the author print "$NamVal{'NumPages'} Pages
\n"; # print the number of pages print "
\n"; # put the data in a borderless table print "
\n"; for ($i = 0; $i < $anum; $i ++) { $np = int($NamVal{'NumPages'} * $perc[$i] / 100); # find number of pages so far print "
 $fract[$i]  $perc[$i]%  $np \n"; # print detail line } # end table print "
\n"; # end html print "\n"; exit 0