in reply to Re^3: what does the retval of can() do ?
in thread what does the retval of can() do ?

Ok, I see, you can call it like:
$a = A->new ; $b = $a->can('test') ; A->$b() if defined $b ; $b = undef ; # de-ref

Thanks

Replies are listed 'Best First'.
Re^5: what does the retval of can() do ?
by chromatic (Archbishop) on Feb 16, 2006 at 06:58 UTC

    I suggest something more like:

    $a->$b() if defined $b;

    ... but whether your code is correct really depends on the implementation of the test() method. I usually see code that just checks whether can() returns a true value.