in reply to defined &{ $pkg . '::foo' } vs. $pkg->can( 'foo' )

There's an additional issue - use of can() depends on a given method which can be overridden to do whatever the package author feels like. Now, this can be useful in the case of AUTOLOAD. However, you may not want AUTOLOADed methods to be brought over in that snippet (nor can some of them be brought over).

The defined way that merlyn did is the safest for general use (I would think), but there are specialized uses that may prefer can().


My criteria for good software:
  1. Does it work?
  2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
  • Comment on Re: defined &{ $pkg . '::foo' } vs. $pkg->can( 'foo' )