audiomobster has asked for the wisdom of the Perl Monks concerning the following question:
I changed it to this:sub PkgContains { my ($package, $sub) = @_; # Return TRUE if $package contains $sub no strict; local(*pkg_symtab) = eval("*${package}::"); return 0 unless defined(%pkg_symtab); return defined($pkg_symtab{$sub}); }
My perl skills are very low so now the questions. What does the code do at all, do my changes make sense and how to improve this? I'm asking because I get an error with one of my make targets which didn't appear before the deprecate warning for "defined(%pkg_symtab)" went to be an error. Thanks in advance and regards, Ulisub PkgContains { my ($package, $sub) = @_; # Return TRUE if $package contains $sub no strict; local(*pkg_symtab) = eval("*${package}::"); if (exists $pkg_symtab{$sub}){ return defined($pkg_symtab{$sub}); }else{ return 0; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: error defined on hash
by choroba (Cardinal) on Dec 22, 2015 at 14:30 UTC | |
by audiomobster (Initiate) on Dec 22, 2015 at 15:22 UTC | |
|
Re: error defined on hash
by kcott (Archbishop) on Dec 22, 2015 at 15:54 UTC | |
|
Re: error defined on hash
by GotToBTru (Prior) on Dec 22, 2015 at 13:55 UTC |