Re: defined on hash value does not work in my code :(
- From: Chris <ithinkiam@xxxxxxxxx>
- Date: Fri, 29 Jul 2005 16:18:11 +0100
saffy wrote:
Sorry, posted too early:-
I have corrected the error and some others, but I still have the problem:-
Basically, the problem boils down to the following, in the code below:-
this line works:- $times1[$#times1 + 1] = sprintf "%s", $db{$months}{$days}{$computernames}{$hours} if ($db{$months}{$days}{$computernames}{$hours} && $cts == 1);
but this one doesn't:- $cts++ unless defined($db{$months}{$days}{$computernames}{$next})
It is working. It's just not doing what (I think) you're expecting. The above only increments $cts when $db{$months}{$days}{$computernames}{$next} is *not* defined, but what I think you what is to increment $cts when the hash *is* defined. Try changing the unless to if and see if that helps.
I doubt it as perl would warn you of any syntax errors. You are using warnings, right?using the debugger shows that $next has the correct value i.e. (when $hour = 00, $next = 01) but for some reason $db{$months}{$days}{$computernames}{$next} does not appear to ever contain a value, even when it should!!
This is probably a silly syntax error on my part or there is something about nested hashes that I don't understand.
.
- Follow-Ups:
- References:
- Prev by Date: Grep uniqueness issue
- Next by Date: Re: Grep uniqueness issue
- Previous by thread: Re: defined on hash value does not work in my code :(
- Next by thread: Re: defined on hash value does not work in my code :(
- Index(es):