#! c:/Perl/bin/Perl.exe -w use strict; use CGI; use CGI::Carp qw/fatalsToBrowser/; use DBM::Deep; use URI::Escape; my $q = CGI->new(); my %params = $q->Vars(); # Start page my $movie = uri_unescape($params{'movie'}); print $q->header( "text/html" ); print $q->start_html(-title => $movie); print $q->h1($movie); my $db = new DBM::Deep ("tag_test.db"); foreach my $param (keys %params) { if ($param eq 'add_tags') { # Add tags my @add_tags = split /,/, $params{$param}; push @{$db->{$movie}}, @add_tags; } elsif ($param ne 'Add/Remove Tags') { for (0..$#{$db->{$movie}}) { # Remove tags if ($param eq $db->{$movie}[$_]) { splice @{$db->{$movie}}, $_, 1; last; } } } } # Start form print $q->start_form(); print $q->textfield(-name => "add_tags"); print $q->table([map {$q->Tr( $q->checkbox(-name => $_))} @{$db->{$movie}}]); print $q->submit(-name => 'Add/Remove Tags'); print $q->end_form(); print $q->end_html;