Loading ...
Sorry, an error occurred while loading the content.
 

Re: [PBML] detect classes?

Expand Messages
  • Dave Gray
    ... This should get you started: #!/usr/bin/perl -w use strict; my $module = Not::Installed ; eval # equivalent to a use statement # but happens on demand,
    Message 1 of 3 , May 24, 2004
      > For example, could the test 'ifexists XML::Simple' be in a case
      > statement and the function that I call be in 'MyXMLmodule' if it exists
      > and be in 'MyFlatFilemodule' if it doesn't?
      >
      > Is there a better way or some Perl magic that does that already?

      This should get you started:

      #!/usr/bin/perl -w
      use strict;

      my $module = 'Not::Installed';
      eval "
      # equivalent to a use statement
      # but happens on demand, not beforehand
      require $module;
      import $module;
      ";
      if ($@) { # if above eval generated an error
      print "$module not installed\n";
      } else {
      print "$module IS installed\n";
      }

      Cheers,
      Dave
    Your message has been successfully submitted and would be delivered to recipients shortly.