in reply to Re: How to determine if a package method is defined
in thread How to determine if a package method is defined
Not really. can checks if a method exists, not if it has been defined.
To check if an inherited method is defined, you needsub foo; print( __PACKAGE__->can('foo') ?1:0,"\n"); # 1 print( defined(&foo) ?1:0,"\n"); # 0 print( exists(&foo) ?1:0,"\n"); # 1
my $method_ref = __PACKAGE__->can('foo'); print( $method_ref && defined(&$method_ref) ?1:0,"\n");
That's said, it's quite likely that the OP should have been using exists and that can will do the trick by itself.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: How to determine if a package method is defined
by almut (Canon) on Oct 01, 2009 at 03:58 UTC | |
by ikegami (Patriarch) on Oct 01, 2009 at 04:00 UTC |