How to test for existance ?

Discussion in 'Perl' started by no spam, Feb 13, 2005.

  1. no spam

    no spam 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.
    ----
    Yves Dorfsman
    http://www.cuug.ab.ca/dorfsmay
    http://www.SollerS.ca
    no spam, Feb 13, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ajit
    Replies:
    5
    Views:
    1,036
    Nicolas
    Sep 26, 2003
  2. james

    Re: Co-existance with VS 6?

    james, Apr 14, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    497
    Michael D. Ober
    Apr 22, 2005
  3. Skybuck Flying

    Call oddities: &Test() vs &Test vs Test

    Skybuck Flying, Oct 4, 2009, in forum: C Programming
    Replies:
    1
    Views:
    693
    Skybuck Flying
    Oct 4, 2009
  4. Jacob
    Replies:
    2
    Views:
    98
    Evertjan.
    Jul 7, 2003
  5. no spam

    How to test for existance ?

    no spam, Feb 21, 2005, in forum: Perl Misc
    Replies:
    2
    Views:
    88
    Brian McCauley
    Feb 21, 2005
Loading...

Share This Page