Hello,
Thanks for quick answer.
>>> In Message "Re: Bug#375938: spampd: configure file is never read"
>>> <[EMAIL PROTECTED]>,
>>> Sven Mueller <[EMAIL PROTECTED]> said;
> Tatsuki Sugiura wrote on 29/06/2006 05:55:
> > "--config" option do not work properly, because $options{'config'}
> > has scalar reference. Mail::SpamAassasin always fail to read config file.
> >
> > Please remove key from %options, or use dereference (like
> > ${options{'config'}}).
> > # Now, I'll attach a patch of key remove version.
> To be honest, I don't really understand your patch. How does removing
> 'config' from %options help? With that path, $options('config') is never
> defined and thus spampd will never even try to read a config file.
> Also, I must admit I'm not Perl expert, but why do the other references
> work as expected while this one doesn't?
GetOptions() will set value into reference if key was defined as
reference before GetOptions() called..., nnnnn, I don't have enough
English skill to explain this...
Please look following code;
---------[ getopt-test.pl ]-------------------------------------------
#!/usr/bin/perl
#
use Getopt::Long;
use Data::Dumper;
my $optfoo = "default-foo";
# pre-define some keys
my %options = (
foo => \$optfoo, # GetOptions() will set into $optfoo
bar => "default-bar", # will be overrided
);
GetOptions(\%options,
'foo=s',
'bar=s',
'baz=s', # new key
);
print Dumper(\%options);
print "foo: ", $options{foo}, "\n";
print "bar: ", $options{bar}, "\n";
print "baz: ", $options{baz}, "\n";
--------------------------------------------------------------------
And try to write this code into getopt-test.pl and run it like;
perl getopt-test.pl --foo=fooval --bar=barval --baz=bazval
So, you'll get a result below;
--------------------------------------------------------------------
$VAR1 = {
'bar' => 'barval',
'baz' => 'bazval',
'foo' => \'fooval',
};
foo: SCALAR(0x814f7e0)
bar: barval
baz: bazval
--------------------------------------------------------------------
You can choice from 3 to get content of "foo" option specified by user;
* use dereference like ${$options{foo}}
* use $optfoo instead of $options{foo}
* remove key 'foo' from %options, and use $options{foo}
> As far as I understand the problem, this should fix it, right? (Just
> pasted here, so mind the unintended linebreaks)
Yes, you took right way.
> PS: Other bug fixed in SVN, will wait with the upload until this one is
> also resolved.
Thanks lot :)
--
Tatsuki Sugiura mailto:[EMAIL PROTECTED]
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]