in reply to Re: Perl OO Lint
in thread Perl OO Lint

Oopsie! Now I see why I wasn't getting the "Can't locate object method...via package..." error. Here is the actual code with names changed to protect the innocent (i.e. me).
eval { $lock->create() }; if (my $exception = My::Execption::Lock::Exists->caught()) { while ($lock->query()) { sleep 180; } exit 0; } die $@ if $@;
Because my if () was always false due to a mispelling, I was just dieing with the prior eval error message, thus supressing the "missing object method" error message. Egads!

My shame for all Perl monks to see.

Replies are listed 'Best First'.
Re^3: Perl OO Lint
by ikegami (Patriarch) on Mar 13, 2006 at 23:13 UTC

    What are you talking about? That code still gives the Can't locate object method "caught" via package "My::Execption::Lock::Exists" (perhaps you forgot to load "My::Execption::Lock::Exists"?) error message.

    The if is never false (as you say) or even true, since perl dies from the type before the if expression gets completely evaluated. Similarly, the die is never reached, since the if encountered a fatal error.

    I suspect the if was within eval's block.

      I see what you mean. Well, damn. I have modified the code so much now that I don't have time to break it and go back to find out exactly what was going on. However, in that same program, I used to have an END{} subroutine that dealt with the same object. Like this:
      eval { $lock->remove() }; if ($@) { if (my $exception = My::Exception::Lock::NotFound->caught()) { warn $exception; } else { die $@; } }
      Maybe that had something to do with why I wasn't getting the object-method-not-found error?