in reply to CGI, Newlines, and If Statements

One suggestion of a general nature I have is to make your matches more tolerant, or provide a list of 'approved' things to search on (in the form of a drop-down list). Don't test for strict equality, test for (case-insensitive) patterns:

foreach my $name (@names) { if ($dbpattern{$name} =~ /$pattern/i or $dbcolor{$name} =~ /$color/ +i) { # print out the record } }

That deals with issues like funky newline problems, etc. (which this version of your code doesn't deal with, although I recall you had put some code in at some point). Although, as I recommend below, you should change the way you store your data, you'll need to chomp each variable:

$i =0; while (my $name[$i] = <DBFILE>) { chomp $name[$i]; my $color = <DBFILE>; my $pattern = <DBFILE>; my $dbcd = <DBFILE>; chomp ($color, $pattern, $dbcd); #yep, all at once! # now go on as before ... $i++; }

I'd also recommend you change the way the information is stored in your flat file; multiline records are relatively more error-prone than single-line records (e.g. what if you accidentally leave out a single line in the file somewhere in the middle? Every record below that will be messed up). Your code could be made more compact if you stored the information as, say, pipe-separated records (just for example: pick a character you know won't end up in the data).

superpicture|TerraCotta|Offset Brick|5

You'd read in a record using something as simple as a split:

chomp $line; my @record = split /\|/, $line, 4; # $record[0] is name, 1 => color 2 => pattern, etc.

and you woulnd't have the problem that a messed up line would mess up everything afterwards.

HTH.

perl -e 'print "How sweet does a rose smell? "; chomp ($n = <STDIN>); +$rose = "smells sweet to degree $n"; *other_name = *rose; print "$oth +er_name\n"'