davorg has asked for the wisdom of the Perl Monks concerning the following question:
Given a reference to a subroutine, how would you go about checking the that referenced subroutine actually exists.
For example if I run
perl -e'print \¬_there'I get back the reference CODE(0xeb570) which _looks_ like a valid subroutine reference, but (of course) isn't as the subroutine it claims to reference doesn't exist.
I suppose you can find out by running the reference in an 'eval' block, but you might not want to do that if the subroutine has potentially dangerous side effects.
--
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Validating a Code Reference
by chromatic (Archbishop) on Aug 17, 2000 at 20:11 UTC | |
by davorg (Chancellor) on Aug 17, 2000 at 20:15 UTC | |
by tilly (Archbishop) on Aug 17, 2000 at 20:26 UTC | |
|
Re: Validating a Code Reference
by davorg (Chancellor) on Aug 17, 2000 at 22:58 UTC | |
|
Re: Validating a Code Reference
by btrott (Parson) on Aug 17, 2000 at 20:11 UTC | |
|
Re: Validating a Code Reference
by tye (Sage) on Aug 17, 2000 at 20:27 UTC | |
|
Re: Validating a Code Reference
by athomason (Curate) on Aug 17, 2000 at 20:17 UTC |