#!/usr/bin/perl -w use strict; use CGI qw(:standard); print header(), start_html("Street Print CD Catalog"), h1("StreetPrint CD Catalog"); ## if the script has been run if (param()) { ##get the color chomp(my $color = param("color")); ## get the pattern chomp(my $pattern = param("pattern")); ## show the 2 received variables print p($color, br(), $pattern); my (%dbcolor, %dbpattern, %dbcd, @name); ## open my DB file open (DBFILE, "form.db") or die "$!"; my $i = "0"; while ($name[$i] = ) { ## put the first line of 4 in name $dbcolor{$name[$i]} = ; ## put the second line of 4 in $dbcolor, referenced with the name ## of the picture $dbpattern{$name[$i]}= ;## put the third line of 4 in $dbpattern, referenced with the name ## of the picture $dbcd{$name[$i]}= ; ## get the cd number of the picture $i++; } close (DBFILE); foreach (@name) { ## if either color or pattern match on the file, show all results that do if (($dbcolor{$_} eq $color) or ($dbpattern{$_} eq $pattern)) { print p($_, br(), $dbcolor{$_}, br(), $dbpattern{$_}, br(), $dbcd{$_}, br()); } } } else { print start_form();## create the form print p("What Color do you want? ", popup_menu("color", ["Any", 'Brick', 'Terracotta','Burnt Sienna','Hunter Green','Safety Blue','White', 'Bedrock','Slate','Sierra'])); print p("What Pattern do you want? ", popup_menu("pattern", ["Any", 'Offset Brick','Herringbone','Herringbone Diagonal','Ashlar Slate','British Cobble','Frisco Cobble','Random Stone','Eurofan'])); print p(submit("Find"), reset("Reset")); print end_form; } print end_html;