Link to home
Start Free TrialLog in
Avatar of QuintusSmit
QuintusSmit

asked on

check if user exists in hash - what am I doing wrong?

Hi

I made this quick scripts to check if the users in a file are loaded into a hash.

this is the file: (txt file)
quintus
renee
usera
userb

and this is the script:

$capfile = "path to file";

 my $x = 0;
 open (CAPPED, $capfile) || die "Can't open file $capfile: $!";
   while (my $line = <CAPPED>) {
      $caplist{$line} = $x;
      $x ++ ;
   }
 close(CAPPED);

if (exists $caplist{"renee"}) {
 print "true";
 }


Why am i not getting a "true"?
ASKER CERTIFIED SOLUTION
Avatar of deiaccord
deiaccord
Flag of Guernsey image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of QuintusSmit
QuintusSmit

ASKER

ahh - thank you