Re: How to check if a function reference is valid or not?
- From: krahnj@xxxxxxxxx (John W . Krahn)
- Date: Wed, 28 Nov 2007 04:11:54 -0800
On Wednesday 28 November 2007 02:15, howa wrote:
sub abc {
print 'abc';
}
my $f1 = \&abc;
my $f2 = \&abcee;
print $f1; # return CODE(0x..)
print $f2; # also return CODE(0x..)
$f1->();
$f2->();
How do I know if $f2 is a valid function reference, without actual
calling it?
$ perl -le'
sub abc {
print 'abc';
}
my $f1 = \&abc;
my $f2 = \&abcee;
print "\$f1 ", defined &$f1 ? "exists" : "does not exist";
print "\$f2 ", defined &$f2 ? "exists" : "does not exist";
$f1->();
$f2->();
'
$f1 exists
$f2 does not exist
Undefined subroutine &main::abcee called at -e line 13.
John
--
use Perl;
program
fulfillment
.
- References:
- Prev by Date: Re: 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: Re: 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):