1Workflow::Condition::EvUasleuratCeo(n3t)ributed Perl DocWuomreknftlaotwi:o:nCondition::Evaluate(3)
2
3
4

NAME

6       Workflow::Condition::Evaluate - Inline condition that evaluates perl
7       code for truth
8

VERSION

10       This documentation describes version 1.62 of this package
11

SYNOPSIS

13        <state name="foo">
14            <action name="foo action">
15                <condition test="$context->{foo} =~ /^Pita chips$/" />
16

DESCRIPTION

18       If you've got a simple test you can use Perl code inline instead of
19       specifying a condition class. We differentiate by the 'test' attribute
20       -- if it's present we assume it's Perl code to be evaluated.
21
22       While it's easy to abuse something like this with:
23
24        <condition>
25          <test><![CDATA[
26            if ( $context->{foo} =~ /^Pita (chips|snacks|bread)$/" ) {
27                 return $context->{bar} eq 'hummus';
28            }
29            else { ... }
30            ]]>
31          </test>
32        </condition>
33
34       It should provide a good balance.
35

OBJECT METHODS

37       new( \%params )
38
39       One of the "\%params" should be 'test', which contains the text to
40       evaluate for truth.
41
42       evaluate( $wf )
43
44       Evaluate the text passed into the constructor: if the evaluation
45       returns a true value then the condition passes; if it throws an
46       exception or returns a false value, the condition fails.
47
48       We use Safe to provide a restricted compartment in which we evaluate
49       the text. This should prevent any sneaky bastards from doing something
50       like:
51
52        <state...>
53            <action...>
54                <condition test="system( 'rm -rf /' )" />
55
56       The text has access to one variable, for the moment:
57
58       $context
59           A hashref of all the parameters in the Workflow::Context object
60

SEE ALSO

62       •   Safe - From some quick research this module seems to have been
63           packaged with core Perl 5.004+, and that's sufficiently ancient for
64           me to not worry about people having it. If this is a problem for
65           you shoot me an email.
66
68       Copyright (c) 2004-2023 Chris Winters. All rights reserved.
69
70       This library is free software; you can redistribute it and/or modify it
71       under the same terms as Perl itself.
72
73       Please see the LICENSE
74

AUTHORS

76       Please see Workflow
77
78
79
80perl v5.38.0                      2023-07-21  Workflow::Condition::Evaluate(3)
Impressum