in reply to When I use "can"
Or to use optimization if possible:if ($whatever) { $self->{callback} = $self->can('a'); } else { $self->{callback} = sub {1}; }
open F, '>', $self->{filename}; if ($other->can('fetch')) { print F, $other->fetch(); } else { while (my $line = $other->read()) { print F, $line; } } close F;
|
|---|