in reply to use module with parameter variable

Another alternative is to use require instead of use:

BEGIN { require Getopt::Declare; import Getopt::Declare $string => $options; }

Replies are listed 'Best First'.
Re^2: use module with parameter variable
by QM (Parson) on Aug 19, 2004 at 21:49 UTC
    I must be missing the point:
    BEGIN { require Getopt::Declare; import Getopt::Declare $string => $options; }
    This implies that $string is defined in an earlier BEGIN, doesn't it?

    -QM
    --
    Quantum Mechanics: The dreams stuff is made of

      $string could be defined inside the BEGIN block, or the BEGIN block could be left out altogether. I only included it in my example out of sheer reflex. :-) Here's another example that might be more useful:

      my $options; my $string = <<'HERE'; -one <one:i> First parameter HERE require Getopt::Declare; import Getopt::Declare $string => $options;