CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
text matching in a pipe-delimited database


Zeke D

Apr 14, 2001, 9:43 AM

Post #1 of 2 (1187 views)
text matching in a pipe-delimited database Can't Post

I am trying to do a search in a pipe-delimited database. A form gathers two variables:
$setfile - the file to search.
$query - the text to match.
Here is the code I have so far, that doesnt work:

sub results2 { 
open ("setfile", "$setfile")||die print "cannot open $setfile.";
@data = <setfile>;
foreach $data (@data) {
$backup = "$data";
if (!($query =~ /$data/i)) {
($cardname,$cost,$type,$class,$power,$tough,$text,$flavor,$set,$rarity,$artist) = split ('[|]',$backup);
print "$cardname<BR>$cost<BR>$type $class<BR>$power/$tough<BR>$text<BR>$flavor<BR>$set<BR>$rarity<BR>$artist<HR>";
} else {
print "";
close (setfile);

It needs to compare the query to each variable in the Database, and each line is a seperate entry.


Apr 14, 2001, 11:30 PM

Post #2 of 2 (1181 views)
Re: text matching in a pipe-delimited database [In reply to] Can't Post

Zeke D,

1. You problem is probably in the line
if (!($query =~ /$data/i)) {
I was unable to understand the meaning of it,
but surely you wanted to use the following:
if ($data =~ /$query/i) {

2. As long as you're not changing the contents
of $data you don't need the $backup.

Jean Spector
QA Engineer @ Extent Technologies, Ltd.


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives