in reply to A web-based checklist in the manner of the checklists in the bathrooms of fast-food restaurants

Ok here is what I am using so far: (very raw)
#!/opt/local/bin/perl # # Script to keep track of peoples' access to their data sources # # # sub showparams{ foreach $a (param()){ $b=param($a); print "param $a has value :$b: <br>"; } } BEGIN { use CGI qw/:standard *table/; use Text::CSV::Simple; $datafile='/dma/lib/www/fst/datachecklist/dataaccess.txt'; my $parser = Text::CSV::Simple->new; my @data = $parser->read_file($datafile); print header(); if (!param('editbutton')){ @now=localtime; #month returned by localtime() are zero-indexed. #got to pad the zeroes for the time/date elements $timestamp=sprintf("%02d-%02d-%04d",$now[4]+1,$now[3],$now[5]+19 +00); @params=param(); unless (param('Cancel')){ foreach $d (@params){ if ($d =~ /-/){ @param1=split(/-/,$d); if ($d =~ /Add/){ unless (param('New service') eq ""){push(@data,[$param1[0],par +am('New service')]);} sub servicesort { $a->[0] cmp $b->[0] } @data=sort servicesort @data; }else{ foreach $c (@data){ if ($c->[0] eq $param1[0]){ if ($c->[1] eq $param1[1]){ $c->[2]=$timestamp; $c->[3]=$param1[2]; } } } } } } } open(FH,">$datafile") || die "Couldn't open datafile: $!"; foreach $g (@data){ print FH join(',', @$g), "\n"; } close(FH); print start_html( -title => "Data Access", -bgcolor => 'purple' +); print start_form(); showparams(); print h6({-align=>'right'},"Today is $timestamp"); my $lastuser; $lastuser=""; foreach $i (@data){ if ($i->[0] ne $lastuser){ print end_table(); print br(),table({-width=>'33%'},Tr(th({-align=>'left'},[$i->[0] +,submit('editbutton',"edit $i->[0]")]))), br(); print start_table({-width=>'33%',-cellpadding=>2,-cellspacing=>0 +,-border=>2,-frame=>'box'}); print Tr(th(['Data Source','Date Last Checked','Check Result'])) +; } print Tr(td($i->[1]),td($i->[2]),td($i->[3])); $lastuser=$i->[0]; } print end_table(); print "\n"; } else{ $user=substr(param('editbutton'),6); print start_html( -title =>"Edit $user", -bgcolor => 'purple' ); print start_form(); showparams(); print h2($user); print start_table({-cellpadding=>2,-cellspacing=>0,-border=>2,-f +rame=>'box'}); print Tr(th(['Data Source','Date Last Checked','Last Check Resul +t','Report Success','Report Failure'])); foreach $i (@data){ if (@$i[0] eq $user){ print Tr(td($i->[1]),td($i->[2]),td($i->[3]),td(submit("$user-$i +->[1]-Pass","Report Success")),td(submit("$user-$i->[1]-Fail","Report + Failure"))); } } print end_table(); print textfield(-name=>'New service'),submit("$user-Addbutton",' +Add new service'),br(); print submit('cancel','Cancel'); } print end_form(); print end_html(); }
I am grappling with how to manipulate the data once it's updated and write it back to the file right now. I could probably cook up a simple routine to write out the CSV data, but I am also going to have to look up how to insert a record into an array at a certain point.

Any and all comments appreciated. T.

_________________________________________________________________________________
Without me, it's just aweso
  • Comment on Re: A web-based checklist in the manner of the checklists in the bathrooms of fast-food restaurants
  • Download Code