Eric Walker wrote: > I have a check I am doing with a hash. > > if (exists $deref{$drcrule}) > > > This check fails as if the keyvalue is a part of the hash, but when I > print out the keys like this > foreach my $item (%{$deref}){ > print "$item\n"; > } > > And it is not in the list. I ran this on a previous data that had this > in the hash, does perl not clean the address space. Is it possible for > this data to be lingering from that last run?
your check: if(exists $deref{$drcrule}) is asking if $drcrule exists in %deref (the hash) but here when you said: foreach my $item (%{$deref}){ print "$item\n"; } you are printing out the keys and values of $deref (the hash reference). remember: %deref = (a => 1,b => 2); #-- hash $deref = {c => 1,d => 2}; #-- hash reference create 2 different variables. your check should probably be: if(exists $deref->{$drcrule}){ #-- ... code ... } example: #!/usr/bin/perl my $stuff = {a => 1, b => 2}; if(exists $stuff{a}){ print "a is there\n"; }else{ print "a is not there\n"; } clearly a is in there but it prints: a is not there do you have 'use strict'? if you have, Perl will complain: Global symbol "%stuff" requires explicit package name at tmp.pl line 7. Execution of tmp.pl aborted due to compilation errors. which tells you there is "bug" in your program. save you a lot of time. learn to 'use strict' and 'use warnings' :-) david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]