How to test for existance ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • no spam

    How to test for existance ?

    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.
    ----
    Yves Dorfsman

    Calgary AIX Linux UNIX React TypeScript JavaScript python contractor consultant programmer Yves Dorfsman


Working...