Workflo...Evaluate(3)
β¨ NAME β¨
Workflow::Condition::Evaluate β bestie, it's an inline condition that evaluates perl code for truth π (and yeah this is from the User Contributed Perl Documentation, section 3 of the manual, iykyk)
π VERSION π
This documentation describes version 2.09 of this package. Periodt.
π¦ SYNOPSIS π¦
Okay so here's the vibe:
state:
- name: foo
action:
- name: 'foo action'
condition:
- test: "$context->{foo} =~ /^Pita chips$/"
πΈ DESCRIPTION πΈ
So like, if you've got a simple test, you can just use Perl code inline instead of specifying a whole condition class. We tell the difference by the 'test' attribute β if it's there, we assume it's Perl code to be evaluated. No cap. π«Ά
Now, the way that it's easy to abuse something like this is with, like:
state:
- name: foo
action:
- name: 'foo action'
condition:
- test: |-
if ( $context->{foo} =~ /^Pita (chips|snacks|bread)$/" ) {
return $context->{bar} eq 'hummus';
}
else { ... }
It should provide a good balance. π
π OBJECT METHODS π
new( \%params )
One of the "\%params" should be 'test', which contains the text to evaluate for truth.
evaluate( $wf )
Evaluate the text passed into the constructor: if the evaluation returns a true value then the condition passes; if it throws an exception or returns a false value, the condition fails. Simple as.
We use Safe to provide a restricted compartment in which we evaluate the text. This should prevent any sneaky bastards from doing something like:
state:
...
- action:
...
- condition:
- test: "system( 'rm -rf /' )"
π Okay so that's the whole point β the restricted compartment is doing the heavy lifting here, do not skip it.
The text has access to one variable, for the moment:
$contextβ a hashref of all the parameters in theWorkflow::Contextobject
π SEE ALSO π
Safeβ From some quick research this module seems to have been packaged with core Perl 5.004+, and that's sufficiently ancient for me to not worry about people having it. If this is a problem for you shoot me an email. β¨
π COPYRIGHT π
Copyright (c) 2004-2021 Chris Winters. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Please see the LICENSE
π§ AUTHORS π§
Please see Workflow
Okay bestie that's the whole page β this was perl v5.42.0, dated 2026-01-17, filed under Workflo...Evaluate(3), and honestly? Iconic. Go write some inline conditions, but stay safe out there πππ¦
π¦ where this page comes from
- fedora 44: perl-Workflow 2.09-2.fc44 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms