Re: How to check if a function reference is valid or not?
- From: paul@xxxxxxxx (Paul Johnson)
- Date: Wed, 28 Nov 2007 13:09:35 +0100
On Wed, Nov 28, 2007 at 02:15:39AM -0800, howa wrote:
sub abc {
print 'abc';
}
print "<", exists &abc, ">\n";
print "<", exists &abcee, ">\n";
my $f1 = \&abc;
my $f2 = \&abcee;
print $f1; # return CODE(0x..)
print $f2; # also return CODE(0x..)
print "<", defined &abc, ">\n";
print "<", defined &abcee, ">\n";
$f1->();
$f2->();
How do I know if $f2 is a valid function reference, without actual
calling it?
perldoc -f exists
perldoc -f defined
Note that a sub exists after taking a reference to it even though it
won't necessarily e defined.
--
Paul Johnson - paul@xxxxxxxx
http://www.pjcj.net
.
- References:
- Prev by Date: How to check if a function reference is valid or not?
- Next by Date: Re: How to check if a function reference is valid or not?
- Previous by thread: How to check if a function reference is valid or not?
- Next by thread: Re: How to check if a function reference is valid or not?
- Index(es):
Relevant Pages
|