Gossamer Forum
Home : General : Perl Programming :

checking file for data

Quote Reply
checking file for data
Hi,

I'm trying to check a txt file for a user inputed field before submitting a form. If the ID exists process the form if not go to error. I originally had it setup where each ID record was a seperate .txt file but just recently combined all the files to one txt file so now I'm not sure how to check one file. This works fine for the old setup:

&error('Not valid.') unless (open(FILE, "/pathto/$form{'ID'}.txt"));

But now the new file is just one pipe deliminated file similar to links:
1|more info|and more info
2|more info|and more info
3|more info|and more info

So I need to check the first field of each record (to make sure it matches what the user inputs) so using the example above, if the user inputs an ID of 2 it will process but if they enter 4 they'll go to the error page.....but not quite sure how to do it. Any ideas? Thanks.


Subject Author Views Date
Thread checking file for data Domenic 10727 Mar 18, 2001, 2:22 PM
Thread Re: checking file for data
Paul 10561 Mar 19, 2001, 7:49 AM
Post Re: checking file for data
Domenic 10477 Mar 19, 2001, 8:11 AM
Thread Re: checking file for data
Mark Badolato 10577 Mar 19, 2001, 8:14 AM
Thread Re: checking file for data
sponge 10548 Mar 20, 2001, 10:46 AM
Thread Re: checking file for data
Paul 10542 Mar 20, 2001, 11:02 AM
Thread Re: checking file for data
Domenic 10527 Mar 20, 2001, 11:38 AM
Thread Re: checking file for data
Paul 10474 Mar 20, 2001, 11:41 AM
Thread Re: checking file for data
Domenic 10512 Mar 20, 2001, 11:48 AM
Thread Re: checking file for data
Paul 10551 Mar 20, 2001, 11:52 AM
Thread Re: checking file for data
Domenic 10464 Mar 20, 2001, 12:25 PM
Post Re: checking file for data
Paul 10464 Mar 20, 2001, 12:49 PM
Thread Re: checking file for data
Domenic 10473 Mar 20, 2001, 1:00 PM
Thread Re: checking file for data
Paul 10459 Mar 21, 2001, 5:10 AM
Thread Re: checking file for data
Domenic 10443 Mar 21, 2001, 8:16 AM
Post Re: checking file for data
Mark Badolato 10428 Mar 21, 2001, 9:08 AM
Thread Re: checking file for data
Paul 10484 Mar 21, 2001, 9:09 AM
Thread Re: checking file for data
Domenic 10430 Mar 21, 2001, 10:21 AM
Thread Re: checking file for data
Paul 10460 Mar 21, 2001, 10:23 AM
Thread Re: checking file for data
Domenic 10424 Mar 21, 2001, 10:46 AM
Thread Re: checking file for data
Paul 10480 Mar 21, 2001, 10:55 AM
Post Re: checking file for data
Domenic 10432 Mar 21, 2001, 3:20 PM
Post Re: checking file for data
Mark Badolato 10452 Mar 20, 2001, 7:09 PM