in reply to Re: rules : action processing like firewall
in thread rules : action processing like firewall

Try following:
my $rules = [ [ sub { do_some_test_here } => sub { do_some_action } ], [ sub { test2 } => [ [ sub { sub_test } => sub { action } ], ], ]; sub process { my ($list, $data) = @_; my $retval; for my $def (@$list) { next unless $def->[0]($data); $retval = ref $def->[1] eq 'ARRAY' ? process ($def->[1], $data) : $def->[1]($data) || 1 ; last if $retval; } $retval; } process ($rules, { iptc => $iptc });

Replies are listed 'Best First'.
Re^3: rules : action processing like firewall
by MacFurax (Initiate) on Mar 26, 2010 at 12:18 UTC
    yeah happy.barney,

    I was exploring that way right now.
    I will just allow rules file to be provided as a parameters (loaded at runtime) to the "rule engine" script.

    Like that I can monitor more than one folder (that will be considered as queues like suggested by roboticus) for new images.
    Each folder will need different processing.
    Images will pass from one folder to an other, giving me my workflow.

    That will also give me kind of multi processing.

    Sound's good to me !

    Thank's for your suggestions !

Re^3: rules : action processing like firewall
by MacFurax (Initiate) on Mar 26, 2010 at 12:27 UTC
    Whow !
    I just realize that you provid "recursion" in the rules !
    Great, I didn't think about it !

    MacFurax