in reply to Re: Testing for key/value match
in thread Testing for key/value match
If you want to test whether a certain key exists and has the value you expect, you can do thisperhaps you mean exists?
if (defined $foo{'bar'} and $foo{'bar'} eq 'baz'){ }
reminder to all: in an array or hash lookup, defined tests for definedness of the value of the array index or hash key, which may not be what you mean. use exists to test whether the array index or hash key is present.if (exists $foo{'bar'} and $foo{'bar'} eq 'baz'){ }
~Particle *accelerates*
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Testing for key/value match
by perlplexer (Hermit) on May 10, 2002 at 15:10 UTC | |
by particle (Vicar) on May 10, 2002 at 15:53 UTC |