My thanks to: Wiggins, Dave, Dennis, Murlidharan and the rest of this
wonderful culture:
Answers to your questions and report on progress.
A form on my web site will invite visitors to register for a free ebook on a
new problem-solving methodology. (You'll get a laugh out of this (my wife
does) -- "If he teaches problem solving methodology why can't he solve his
own problems?" !!)
Visitors will never read the stored data file. I will access it only
occassionally (~monthly).
The form will submit data to the cgi script below for appending to a
data-base file (haven't been able to get hash appending to work). The script
creates a time stamp, TS, that would be convenient for referencing visitor's
data, as well as for sorting these data when printing. I will need a java
script to create a drop-down window with names of countries for the
visitor's selection -- I'll work on this later.
These data will be stored in a HoH in which order is of no concern, they
will be sorted when the database is interrogated.
##### SCRIPT FOR STORING VISITOR DATA
### Name and Country will be submitted by a form that calls this script
use CGI qw/:standard/;
use MLDBM qw(DB_File Storable);
use DB_File ;
use vars qw(%visitor_bffr $LN $CN $TS %visitordata %newH $dbm %storedH);
%visitor_bffr = ( ## data from form
'LN' => param('LN'), ## Last name
'CN' => param('CN'), ## Country
);
$TS = time();
### Stored HoH components to be dereferenced as $visitordata{TS}{LastName}
=> LN
### and $visitordata{TS}{Country} => CN
### where TS is the outerkey, LastName and Country are innerkeys.
### *** Stored HoH structure ***
###
### hashname outerkey innerkey
### | | |
### %visitordata = (
### $TS => {
### LastName = LN,
### Country = CN,
### },
### ... next appended hash here (I hope) ...
### );
### Save this information as a new hash appended to an existing HoH
$newH{'TS'} = $TS;
$newH{'TS'}{'LN'} = $LN;
$newH{'TS'}{'CN'} = $CN;
$dbm = tie %storedH, 'MLDBM', 'visitordata.dbm', O_CREAT|O_RDWR, 0640
or die "Cannot open file 'clients': $!\n";
%dbm = ($dbm, %newH); #!!# This doesn't seem to work!
undef $dbm;
untie %storedH;
-------------------------------------
### SCRIPT FOR INTERROGATING STORED VISITOR DATA
### *** Printed HoH format ***
###
### %visitordata =
### Mon Apr 5 16:23:33 2002 Last Name = Sickafus
### Country = USA
###
### Tue Jan 21 15:39:02 2003 Last Name = Washington
### Country = France
### When the stored hash is interrogated it will be sorted on TS and printed
use CGI qw/:standard/;
use MLDBM qw(DB_File Storable);
use DB_File ;
use vars qw($keyouter $keyinner $dbm %storedH);
$dbm = tie %storedH, 'MLDBM', 'visitordata.dbm', O_CREAT|O_RDWR, 0640
or die "Cannot open file 'clients': $!\n";
foreach $keyouter(sort keys %dbm){
print localtime($dbm{kouter}) "\t";
foreach $keyinner(keys %{$dbm{$keyouter}})
If ($dbm{$kouter}{keyinner} == 'LN')
{
print "Last Name = $dbm{$kouter}{keyinner}\n";
}
else
{
print "Country = $dbm{$kouter}{keyinner}\n";
}
};
undef $dbm;
untie %storedH;
#?# It seems to me that the above will sort only keyouter since sort doesn't
know
## that inner levels of a hash exist in %dbm -- does it?
Very grateful for your support.
Ed
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]