How to test for existance ?

G

Guest

Here's a small script to show what I am trying to do:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#!/usr/bin/perl -w

sub print_yep
{
print "yep...\n";
}


$function1 = "print_yep";
$function2 = "rubbish";

$vector->{ACTION1} = \&$function1;
$vector->{ACTION2} = \&$function2;

print "something's fishy !\n" if (! exists $vector->{ACTION2});

$vector->{ACTION1}();
$vector->{ACTION2}();

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

How can I test if a function exist or not ?
Shouldn't this print "something's fishy" ??
I've tried to use defined, to deference in different ways, but I can't get
it working.


Thanks,


Yves.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top