---
name: "Net::Sieve::Script::Rule"
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::Rule"
---

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

parse and write rules in sieve scripts

## NAME

Net::Sieve::Script::Rule - parse and write rules in sieve scripts

## SYNOPSIS

```
  use Net::Sieve::Script::Rule;
        my $pRule = Net::Sieve::Script::Rule->new (
            ctrl => $ctrl,
            test_list => $test_list,
            block => $block,
            order => $order
            );
```

or\
     my `$rule` =  Net::Sieve::Script::Rule-\>**new()**;\
     my `$cond` = Net::Sieve::Script::Condition-\>new('header');\
        `$cond`-\>match\_type(':contains');\
        `$cond`-\>header\_list('"Subject"');\
        `$cond`-\>key\_list('"Re: Test2"');\
     my `$actions` = 'fileinto "INBOX.test"; stop;';

```
      $rule->add_condition($cond);
      $rule->add_action($actions);
      print $rule->write;
```

## DESCRIPTION

## CONSTRUCTOR

### new

```
    Arguments :
        order =>     : optional set priority for rule
        ctrl  =>     : optional default 'if', else could be 'else', 'elsif'
                       or 'vacation'
        test_list => : optional conditions by string or by Condition Object
        block =>     : optional block of commands
    Returns   :   Net::Sieve::Script::Rule object
```

Set accessors

```
  alternate  : as param ctrl
  conditions : first condition in tree
  actions    : array of actions objects
  priority   : rule order in script, main id for rule
  require    :
```

## METHODS

### equals

return 1 if rules are equals

### write

```
 Return rule in text format
```

### write\_condition

```
 set require for used conditions
 return conditions in text format
```

### write\_action

```
 set require for used actions
 return actions in text format
```

### delete\_condition

```
 Purpose   : delete condition by rule, delete all block on delete anyof/allof
             delete single anyof/allof block : single condition move up
 Arguments : condition id
 Returns   : 1 on success, 0 on error
```

### add\_condition

```
 Purpose   : add condition to rule, add 'allof' group on second rule
 Arguments : string or Condition object
 Returns   : new condition id or 0 on error
```

### swap\_actions

```
 swap actions by order
 return 1 on succes, 0 on failure
```

### find\_action

```
 find action by order
 Returns:  Net::Sieve::Script::Action object, 0 on error
```

### delete\_action

delete action by order, first is 1;

### add\_action

```
 Purpose   : add action at end of block
 Arguments : command line
             or command line list with ; separator
             or Net::Sieve::Script::Action object
 Return    : 1 on success
```

## 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.
