wiz has asked for the wisdom of the Perl Monks concerning the following question:
Well my boss made me take a perfect running script, and dig out the insides, and make a new script from it. Well here is new script, in all it's inefficentness. :P Problem with the script, all features in it don't work :P It doesn't search
#!/usr/bin/perl -w use strict; use CGI qw(:standard); ## start file print header(), start_html(-title=>"Street Print CD Catalog", -background=>'/image +s/catalogbackground.jpg'); print "<img src=\"/images/StPrintImageLogo2.gif\"><br><br>"; ##collect the data from my forms page my $filename = param('filename'); ## a text box to enter in a ## whole or part file name my $color = param('color');## pull down menu ## searches color types. default Any my $pattern = param('pattern'); ## pull down menu ## searches pattern types. default Any my $Typeofprint = param('Typeofprint'); ## A dialog of radio ## buttons. Submitted data looks like either a single number, ## or a list of numbers ex) "1" or "1 2 3 15 22" my $highres = param('highres'); ## yes or no high res chomp ($filename, $color, $pattern, $Typeofprint, $highres); ## make s +ure no \n stuff follows it ## the beginning of the table print "<table border=1><tr align=\"center\" valign=\"middle\"><td widt +h =\"150\"><h3>Name</h3><h6>Picture number<br>followed by name</h6></ +td><td width =\"100\"><h3>Color</h3></td><td width =\"100\"><h3>Patte +rn</h3></td><td width =\"100\"><h3>CD Number</h3></td><td width =\"10 +0\"><h3>High res, 300 dpi image available on CD?</h3></td><td width = +\"150\"><h3>Thumbnail Image</h3><h6>**Click to enlarge**</h6></td></t +r>"; ## open the DBFILE, located in the same directory open (DBFILE, 'scfrom.db') or die "$!"; ## for each line of the DBFILE while (my $line = <DBFILE>) { chomp $line; $line =~ tr/\r\n//d;## get rid of white space my @record = split /\|/, $line, 7; ## split it up into.... ## $record[0] is name, 1 => color, 2 => pattern, 3 => cd, ## 4 => thumbnail picture, 5=> screen res picture, 6=> yes or no high +res. my @cdnumbers = split / /, $Typeofprint; ## split by whitespace, ## so cd numbers don't run into eachother ## ex 1 isn't in 12 :P if ($color eq "Any" || $record[1] =~ /^$color$/i ## if color is Any or matches the DBFILE and $pattern eq "Any" || $record[2] =~ /^$pattern$/i ## if patter +n is Any or matches DBFILE and $highres eq "Any" || $record[6] eq 'Yes' ## if highres is Any or if the record says Yes or $filename =~ /^$record[0]$/igc ## if file name is located in $record[0]) { my $i; ## while the $cdnumbers for that selection are checked by the DBFILE while ($cdnumbers[$i]) { if ($Typeofprint eq "Any" or $cdnumbers[$i] =~ /^$record[3]$/i) ## if +it's any or it matches { print "<tr align=\"center\" valign=\"middle\"><td width=\"150\">$recor +d[0]</td><td width=\"100\">$record[1]</td><td width=\"100\">$record[2 +]</td><td width=\"100\">$record[3]</td><td width=\"100\">$record[6]</ +td><td width=\"150\"><a href=\"/images/screenres/$record[5]\"><img BO +RDER=\"0\" src=\"/images/thumbnails/$record[4]\"></td></tr>\n"; ## th +e actual code :) next; } } } } print '</table>'; print end_html;
Here is the form page, and Here is the DB file.
----------------------------
Wiz, The VooDoo Doll
Head Master of 12:30 Productions
----------------------------
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: My Image Search, v2
by Zaxo (Archbishop) on Aug 15, 2001 at 01:09 UTC | |
|
Re: My Image Search, v2
by wiz (Scribe) on Aug 15, 2001 at 00:48 UTC |