
CuzDesign
Deleted
May 30, 2000, 1:50 AM
Post #3 of 4
(333 views)
|
|
Re: Help, Testin Data in file with Field in form.
[In reply to]
|
Can't Post
|
|
Thanks perlkid for the fast reply. I tried what you gave me here and works great for the testing the first code you put up, cause I need it to be case sensative. The only problem I am having is while it is testing it just keeps looping even after it has found a match. How do you make it stop after it finds a match? Here is the code I am using as you put it in: <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> $stock = param('stock'); open(DATA, "<cars.dat"); @all=<DATA>; close(DATA); foreach $line (@all){ @array=split(/:/, $line); if ($array[1] eq "$stock"){ print "Stock number already exsists\n"; }else{ print "Stock number added\n"; } } </pre><HR></BLOCKQUOTE> That causes a loop to print to the page so I tried it this way and doesnt test all, but always says already added even when not in data file: <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> $stock = param('stock'); open(DATA, "<cars.dat"); @all=<DATA>; close(DATA); foreach $line (@all){ @array=split(/:/, $line); if ($array[1] eq "$stock") { $good = 1; last; } } if (!$good) { print "Stock number already exsists\n"; }else { print "Stock number added\n"; } </pre><HR></BLOCKQUOTE> Can anyone see why this doesn't work? Thanks, Ray
|