in reply to When I use "can"

Checking my current work application, the main reason I use can is when I'm about to call something that needs a callback supplied:

# template->capture(pattern, object, callback) # - replace each occurrence of <pattern> in the template # with the result of calling <callback> on <object> $template->capture('%id%', $self, $self->can('id'));
Note that in this situation, I know that the object must support the method.

The other 3 uses each use only the boolean result:

(I also have three AUTOLOAD subs defined in the same application: the one described above; one for a 'security wrapper' class that pretends to be the wrapped object but blows up if you attempt to call any unpermitted methods; and one dummy object (which also provides its own can method) to allow some parts of the application to be used on an uninstalled copy.)

Hugo