G'day All,
Just wondering how I would check the following variable against the hash
below?
sub read_data {
open USER_DATA, "$USER_DATA" or warn "cannot open '$USER_DATA' for
reading: $!\n";
flock(USER_DATA, 2) || warn "Can't lock $USER_DATA exclusively: $!";
while( $USER_DATA=<USER_DATA> ) {
@USER_DATA = split (/,/, $USER_DATA);
s/^"|"$//g foreach @USER_DATA;
$username = $USER_DATA[0];
$company = $USER_DATA[2];
$owing = $USER_DATA[3];
$users{$username}{$company} = $owing;
}
close USER_DATA;
return %users;
}
read_data();
The sub read_data will create a hash similar to the following...
%users = (
'username01' => {
'Comp01' => '$0.00'
},
'username02' => {
'Comp02' => '$0.00'
},
'usename03' => {
'Comp03' => '-$9.90'
}
);
My questing is if I have the following variable...
$variable = "usename01";
How can I check that against the hash above. If $variable doesn't match
anything the print "Username does not match";
Kind Regards,
Dan
==============================
VINTEK CONSULTING PTY LTD
(ACN 088 825 209)
email: [EMAIL PROTECTED]
web: <http://www.vintek.net>
Tel: (08) 8523 5035
Fax: (08) 8523 2104
Snail: P.O. Box 312
Gawler SA 5118
==============================
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]