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"?
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER