# Line 20-24 my $year = $cgi->param('year') ? encode_entities($cgi->param('year +'), '<>"') : ''; my $media = $cgi->param('media') ? encode_entities($cgi->param('medi +a'), '<>"') : ''; my $genre = $cgi->param('genre') ? encode_entities($cgi->param('genr +e'), '<>"') : ''; my $source = $cgi->param('source') ? encode_entities($cgi->param('sour +ce'), '<>"') : ''; my $title = $cgi->param('title') ? encode_entities($cgi->param('titl +e'), '<>"') : '';
[download]
# How I'da dunnit: my %param = map { $cgi->param($_) ? ($_ => encode_entities($cgi->param($_), '')) : () } qw(year media genre source title);
[download]
# Line 33-39: if ( $year || $media || $genre || $source || $title ) { my @selections; push @selections, qq($title) if $title; push @selections, qq($year) if $year; push @selections, qq($media) if $media; push @selections, qq($genre) if $genre; push @selections, qq($source) if $source; ...
[download]
# How I'da dunnit: if (keys %param) { my @selections = values %param; ...
[download]

As for verything from line 82 onward, i.e. the whole page(...) thing, I'd look into a templating system. Template Toolkit follows the Perl philosophy (easy things easy, hard things possible) pretty neatly in my opinion.