QM has asked for the wisdom of the Perl Monks concerning the following question:
To use this form of G::D, $string and $options must exist (such as with my), and $string must be defined, such as through a BEGIN (before the compiler sees use Getopt::Declare).#!/your/perl/here use strict; use warnings; my $options; my $string; BEGIN { $string = <<'HERE'; -one <one:i> First parameter HERE } use Getopt::Declare $string => $options; ### <<< BONK! print "one = $options->{-one}\n";
To avoid this, at least with G::D, use the following instead:
You can use a banana to drive a nail, but you'll need to precondition the nail, or the banana, or both.use Getopt::Declare; $options = Getopt::Declare->new($string);
-QM
--
Quantum Mechanics: The dreams stuff is made of
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: use module with parameter variable
by revdiablo (Prior) on Aug 19, 2004 at 16:53 UTC | |
by QM (Parson) on Aug 19, 2004 at 21:49 UTC | |
by revdiablo (Prior) on Aug 19, 2004 at 21:57 UTC |