in reply to Simple Query on Operators
I can't see why the following line of code would throw an interpreter warning (useless use of hash in void context...)
It doesn't. It doesn't even compile. I bet the line is really
my $foo = defined($some_hash{bar}) and $some_hash{bar};
which is the same thing as
( my $foo = defined($some_hash{bar}) ) and $some_hash{bar};
where the result of defined is assigned to $foo and $some_hash{bar} never is. Perhaps you want
my $foo = defined($some_hash{bar}) && $some_hash{bar};
or
my $foo = ( defined($some_hash{bar}) and $some_hash{bar} );
Take care, or and and have very low precedence.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Simple Query on Operators
by Ewok_Wrangler (Initiate) on Mar 04, 2008 at 16:54 UTC |