in reply to Re: Re: Re: Re: Calling can method
in thread Calling can method

When $x isn't a blessed reference!

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Class Name versus Blessed Referent
by chromatic (Archbishop) on May 30, 2001 at 21:08 UTC
    Or when it doesn't contain a class name:
    package Test; sub foo {}; package main; if (Test->can('foo')) { print "Hardcoded can works!\n"; } my $t = 'Test'; if ($t->can('foo')) { print "Variable can works!\n"; }
    Now you or I wouldn't usually let that pass in a code review, which is why I go the extra step of invoking UNIVERSAL::can(). But we both know one dirty little secret of OO Perl, that it's the class name that's important, not the fact that something has been blessed.