in reply to Re: How do I test the validity of a CODE reference?
in thread How do I test the validity of a CODE reference?

The reason I decided to use eval is that the user can put the required code in a package, and I don't need to know anything about it as long as he uses the fully qualified name as the subroutine name.

Out of curiosity, how would you examine the symbol table for a package whose name you get from a variable? I'm not very comfortable with the syntax for typeglobs and Perl symbol tables...

Replies are listed 'Best First'.
Re^3: How do I test the validity of a CODE reference?
by Corion (Patriarch) on Aug 09, 2008 at 08:45 UTC

    You can inspect any package, as the symbols for My::Package live in the %My::Package:: hash. The easiest way to get at those hashes is via soft references:

    use strict; use Data::Dumper; my $package = 'Data::Dumper'; # just as an example { no strict 'refs'; # we're using strings as symbols. Nasty, but con +venient warn Dumper \%{ "$package\::" }; };