in reply to Re: optimization - exists should return a reference
in thread optimization - exists should return a reference

I don't quite follow you?

print $$ref if my $ref = exists %hash{something);

Update Above replaced after Abigail-II's post below.

print $$_ if $_ = exists $hash{something);

Regardless of what false value is returned by exists if the thing doesn't exist, the if will be false and so $ref will never be dereferenced.

Or am I missing something as usual?


Examine what is said, not who speaks.

The 7th Rule of perl club is -- pearl clubs are easily damaged. Use a diamond club instead.

Replies are listed 'Best First'.
Re: optimization - exists should return a reference
by Abigail-II (Bishop) on Jan 15, 2003 at 13:39 UTC
    That won't do what you think it does. Remove the my for it to work.

    Abigail

      Good point. I'm always doing that in real code too. I substituted $_ for the purposes of the example, but I realise that may not be useful in many situations.


      Examine what is said, not who speaks.

      The 7th Rule of perl club is -- pearl clubs are easily damaged. Use a diamond club instead.