package Foo; sub new { bless {}, shift } sub foo { print "i'm a method of Foo\n" } package main; my $o = Foo->new(); print "foo exists\n" if $o->can('foo'); print "bar does not exist\n" unless $o->can('bar'); __output__ foo exists bar does not exist