## increment the sequencer. $HoA{sequence} = 0 unless exists $HoA{sequence}; my $i = ++$HoA{sequence}; print ("HoA sequence: $HoA{sequence} \n"); my $date = strftime('%d-%b-%Y %R',localtime); $HoA{$i} = [ ($date), map {escape(param($_))} (@FIELDS) ]; print ("HoA newvalue $i: $HoA{$i} \n" ); print ("HoA newvalue $i: $HoA{$i}[0] \n" ); print ("HoA newvalue $i: $HoA{$i}[1] \n" ); print ("HoA newvalue $i: $HoA{$i}[2] \n" ); print ("HoA newvalue $i: @{ $HoA{$i} } \n" ); print ("HoA newvalue $i: " . @{ $HoA{$i} } ."\n" ); $HoA{test} = [ "aaa", "bbb", "ccc" ]; print ("HoA test $i: " . $HoA{test} ."\n" ); print ("HoA test $i: " . $HoA{test}[0] ."\n" ); print ("HoA test $i: " . $HoA{test}[1] ."\n" ); print ("HoA test $i: " . $HoA{test}[2] ."\n" ); print ("HoA test $i: @{ $HoA{test} } \n" ); # returns list print ("HoA test $i: " . @{ $HoA{test} } ."\n" ); # returns count #### sub write_guestbook { unless (TieLock($GUESTBOOKFILE, 1)) { print strong('Sorry, an error occurred: unable to open ' . $GUESTBOOKFILE),p(); return; } ## increment the sequencer. $HoA{sequence} = 0 unless exists $HoA{sequence}; my $i = ++$HoA{sequence}; my $date = strftime('%d-%b-%Y %R',localtime); $HoA{$i} = join(">", ($date), map {escape(param($_)) ." } (@FIELDS) ); unTieLock($GUESTBOOKFILE); return( "Thank you ". param('First_Name') .", for signing the guestbook."); } sub view_guestbook { my $guestbook; my @rows; unless (TieLock($GUESTBOOKFILE, 0)) { print strong('Sorry, an error occurred: unable to open ' . $GUESTBOOKFILE),p(); return; } for my $addr (sort keys %HoA) { next if $addr eq "sequence"; my @data = map {unescape($_)} split( ">", $HoA{$addr} ); unshift @rows, td(\@data); } unshift @rows, th(['Entry Date',@FIELDS]); $guestbook .= p( table({-border=>'1', -hspace=>'5', -cellspacing=>'1', -cellpadding=>'4'}, TR(\@rows))); unTieLock($GUESTBOOKFILE); return ($guestbook); }