in reply to caller package and eval

caller indicates the package in effect when the calling code was compiled. If you want to change what caller returns, you'll need to change what package directive is in effect when the calling code was compiled.

...but are you sure you want caller? What's on the left-hand side of the arrow (->) is passed to the method as the first argument, not via caller.

Replies are listed 'Best First'.
Re^2: caller package and eval
by josh803316 (Beadle) on Sep 02, 2009 at 01:55 UTC
    You mean just use if $class->isa instead of worrying about the caller. Thanks, that makes sense....I got too stuck copying example code I think.
      I don't understand how isa fits in here. If you mean to do the following, it seems useless to me.
      package User; sub find { my ($class, $query) = @_; die("Bad class") if !$class->isa('User'); ... }

      Someone would have to put effort into making that condition fail.

        Yeah, I agree, it seems to be overkill and not really necessary. It seems I don't need the isa test at all, although I was trying to be protective inside my parent object. Thank you very much for your helpful responses.