wiz has asked for the wisdom of the Perl Monks concerning the following question:
#!/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] = <DBFILE>) { ## put the first line of 4 in name $dbcolor{$name[$i]} = <DBFILE>; ## put the second line of 4 in $ +dbcolor, referenced with the name ## of the picture $dbpattern{$name[$i]}= <DBFILE>;## put the third line of 4 in $d +bpattern, referenced with the name ## of the picture $dbcd{$name[$i]}= <DBFILE>; ## 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(), $d +bcd{$_}, 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", 'O +ffset Brick','Herringbone','Herringbone Diagonal','Ashlar Slate','Bri +tish Cobble','Frisco Cobble','Random Stone','Eurofan'])); print p(submit("Find"), reset("Reset")); print end_form; } print end_html;
Now the file that is being run here and the DB file is being run here.
----------------------------
Wiz, The VooDoo Doll
Head Master of 12:30 Productions
----------------------------
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: CGI, Newlines, and If Statements
by arturo (Vicar) on Jul 18, 2001 at 22:46 UTC | |
|
Re: CGI, Newlines, and If Statements
by rucker (Scribe) on Jul 18, 2001 at 21:50 UTC | |
|
Re: CGI, Newlines, and If Statements
by wiz (Scribe) on Jul 18, 2001 at 23:09 UTC | |
|
Re: CGI, Newlines, and If Statements
by rrwo (Friar) on Jul 19, 2001 at 01:24 UTC | |
|
Re: CGI, Newlines, and If Statements
by wiz (Scribe) on Jul 18, 2001 at 21:58 UTC | |
by rucker (Scribe) on Jul 18, 2001 at 22:40 UTC |