Good morning,

I would like to populate a hash from a csv text file, then test for the 
existence  of a value in the hash.
If not found return an error message and exit.


ithe text file will have the format of:
# whitelist created 2/18/06 or some other comment on the first line
name1,nick1
---
name25,nick25
---

my $approvedUser = pram('approvedUser'); # cgi.pm

my $whitelist = './'whitelist.txt;

my %hash

open(EL,"$whitelist") ||  &errorMessage( "Read in, Could not find $whitelist, 
$!");
my @lines = <EL>;
close(EL);

foreach(@lines){
    next if /#/;
    my($key,$val)= split (@lines,",");
   $hash{$key} = $val;
 }
close(EL);

if (!defined $approvedUser =~ %hash){
    &errorMessage( "your not an authorized user")
}


errorMessage(message){
shift;
print "$_\n";
exit;
}


How close am I to having a working script, I have guessed at some of syntax 
here, and am not familiar 
with using 'defined'.

Thanks for any guidance.

Regards from Cow Town,
David Gilden
(kora musician / audiophile / webmaster @ www.coraconnection.com  / Ft. Worth, 
TX, USA) 

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to