---
name: "Net::Sieve::Script::Condition"
section: "3pm"
platform: "linux"
package: "libnet-sieve-script-perl"
version: "0.09-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Net::Sieve::Script::Condition"
---

# Net::Sieve::Script::Condition(3pm)

parse and write conditions in sieve scripts

## NAME

Net::Sieve::Script::Condition - parse and write conditions in sieve scripts

## SYNOPSIS

```
  use Net::Sieve::Script::Condition;
  my $cond = Net::Sieve::Script::Condition->new('header');
    $cond->match_type(':contains');
    $cond->key_list('"[Test4]"');
    $cond->header_list('"Subject"');
   print $cond->write();
```

or

```
   my $cond = Net::Sieve::Script::Condition->new(
     'anyof (
       header :contains "Subject" "[Test]",
           header :contains "Subject" "[Test2]")'
         );
   print $cond->write();
```

## DESCRIPTION

Parse and write condition part of Sieve rules, see Net::Sieve::Script.

Support RFC 5228, 5231 (relationnal) and regex draft

## CONSTRUCTOR

### new

Match and set accessors for each condition object in conditions tree, "test" is mandatory

Internal

```
  id :        id for condition, set by creation order
  condition : array of sub conditions
  parent :    parent of sub condition
  AllConds :  array of pointers for all conditions
```

Condition parts\
   not          : 'not' or nothing\
   test         : 'header', 'address', 'exists', ...\
   key\_list     : "subject" or \["To", "Cc"\]\
   header\_list  : "text" or \["text1", "text2"\]\
   address\_part : ':all ', ':localpart ', ...\
   match\_type   : ':is ', ':contains ', ...\
   comparator   : string part

## METHODS

### equals

```
 Purpose  : test conditions
 Return   : 1 on equals conditions
```

### write

```
 Purpose  : write rule conditions in text format
 Return   : multi-line formatted text
```

## AUTHOR

```
    Yves Agostini
    CPAN ID: YVESAGO
    yvesago@cpan.org
```

## COPYRIGHT

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.
