Gary,

> The square brackets in the example [5.0] would only be required if there
> were a list of values; the brackets could be used here (there is a list
> of 1 value), but for a _maps setting like this (that normally would
> take a list of values), the brackets are not required when there is
> only a single value. The final_*_destiny settings only take a single
> value, not a list.
>
> So, this should be Ok too:
>
> $policy_bank{'MYNETS'} = {  # mail originating from @mynetworks
>    spam_tag2_level_maps => [5.0],
>    spam_kill_level_maps => [18.0],
>    final_virus_destiny      => D_BOUNCE,
>    final_banned_destiny     => D_BOUNCE,
>    final_spam_destiny       => D_DISCARD,
>    final_bad_header_destiny => D_BOUNCE,
> };
>
> Mark, I'm kind of winging it here. I hope I'm not too far off. :)

You are doing alright, thanks!
The above example looks fine.


> the brackets are not required when there is only a single value

True, due to special concession in sub cr, which fetches array-type
keys (like *_maps) from policy banks:

# return a ref to a config variable value (which is supposed to be an array),
# converting undef to an empty array, and a scalar to a one-element array
# if necessary
sub ca($) { ... }

Also Perl itself is merciful if someone assigns a scalar
to an array-type variable (variable name starting with @),
and automatically supplies missing parenthesis - although
it is ugly to rely on this. When an list (=array) is called-for
in an assignment, please provide a list, e.g.:
  @bypass_spam_checks_maps = (1);
and not a single scalar like:
  @bypass_spam_checks_maps = 1;  # ugly, Perl converts
                                 # a scalar 1 into a list (1)

Similarly in policy banks,
correct:
$policy_bank{'TEST'} = {
  bypass_spam_checks_maps => [1],
};

and not a sloppy:
$policy_bank{'TEST'} = {
  bypass_spam_checks_maps => 1,
};

which happens to work, converting a scalar 1 into
an array reference [1] by a routine cr.



>From RELEASE_NOTES when policy banks were introduced:

  A word of caution: the syntax of entries within a policy bank hash
  is slightly different from assignments to configuration variables.
  This is because entries within policy bank are not asssignments, but
  key=>value pairs as in any Perl hash. And these pairs are delimited by
  commas, unlike statements, which are delimited by semicolons.
  Value is separated from its key by '=>' (or by a comma), whereas the
  assignment operator is '='. Keys of a policy bank are without leading
  $ or @ or %, unlike variable names. Values of a hash can only be scalars
  (e.g. strings or references).

  Compare:
  - value of a policy bank is a reference to a Perl hash, e.g.:
    { log_level => 3,
      forward_method => 'smtp:[127.0.0.1]:10025',
      spam_admin_maps => ["[EMAIL PROTECTED]"],
    }
  - normal assignments look like:
      $log_level = 3;
      $forward_method = 'smtp:[127.0.0.1]:10025';
      @spam_admin_maps = ("[EMAIL PROTECTED]");


Mark

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
AMaViS-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/amavis-user
AMaViS-FAQ:http://www.amavis.org/amavis-faq.php3
AMaViS-HowTos:http://www.amavis.org/howto/

Reply via email to