ninuzzo has asked for the wisdom of the Perl Monks concerning the following question:

How can I use a module like Inline::Java with a bunch of parameters? Namely: I need to determine both a minimum version, an import list and some options. Specifically I'd like to use the DIRECTORY option but without any Java code to execute. I am actually using:
use Inline (Java => ';', DIRECTORY => ...); import Inline::Java qw(cast coerce);
but there is now way to force the module version (in my case 0.52_90+) and I had to put an empty Java instruction which may slow down my program.
  • Comment on use a module: need version, import list and some parameters at the same time
  • Download Code

Replies are listed 'Best First'.
Re: use a module: need version, import list and some parameters at the same time
by ikegami (Patriarch) on Feb 22, 2011 at 19:16 UTC

    One statement "imports" from Java, the other from Inline::Java. Unless you happen to have a reason to believe they can be combined, it's not likely.

    It should be possible to add the version check in there, though.

    use Inline (Java => ';', DIRECTORY => ...); use Inline::Java 0.52_90 qw( cast coerce );

    I had to put an empty Java instruction which may slow down my program.

    Your focus is entirely misplaced. Doing a few small things at compile-time should not have a significant impact on your program's performance.

      Thanks for your answer. You are right it is not a big overhead. Anyway there is a cure for that:
      BEGIN { # Make sure the directory exists before using Inline. mkdir '/tmp/_Inline'; } use Inline (Java => Config => DIRECTORY => '/tmp/_Inline'); use Inline::Java 0.52_90 qw( cast coerce );
      Quoting the Inline POD: "The special keyword 'Config' tells Inline that this is a configuration-only call. No source code will be compiled or bound to Perl"