How to test for existance ?

From: no spam (uce_at_ftc.gov)
Date: 02/13/05

  • Next message: Mark: "Newbie: test array for lower case"
    Date: Sun, 13 Feb 2005 01:21:43 GMT
    
    

    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
    

  • Next message: Mark: "Newbie: test array for lower case"

    Relevant Pages

    • How to test for existance ?
      ... Here's a small script to show what I am trying to do: ... sub print_yep ... I've tried to use defined, to deference in different ways, but I can't get ... Yves Dorfsman ...
      (comp.lang.perl.misc)
    • Re: Detecting is hyperthreading is enabled with WMI?
      ... It is too bad that WMI does not give this info. ... have to be done to the script. ... Public Sub DisplayProcessorInfo ... dim ProcessorSet, Processor ...
      (microsoft.public.windowsxp.wmi)
    • Cant make this page work
      ... I can't make this script work properly. ... The script at the bottom of the html page ... Does someone have a perl ... sub output_trace_headers { ...
      (comp.lang.javascript)
    • Re: Win32_Product doesnt list all installed Applications
      ... 'Must have ADSI and WMI installed on PC running script. ... CONST ForReading = 1 ... Sub Connect ... strHTML = "Smoke'm if you Got'em" ...
      (microsoft.public.windows.server.scripting)
    • Win32_Product doesnt list all installed Applications
      ... 'Must have ADSI and WMI installed on PC running script. ... CONST ForReading = 1 ... Sub Connect ... strHTML = "Smoke'm if you Got'em" ...
      (microsoft.public.windows.server.scripting)