Hi,
I'm extending Perl::Pie package to include more deterministic rules that can be triggered in some certain time moments (new seconds, every 5 secs, etc...). Rules consists of conditions that must be true, so actions in the list get executed.
I've add some simple time related functions (new_second, new_hour, ...) and variables ($Week_day, $Day, $Hour) in the additional time.pl file. I've included it in main file with
require 'time.pl';
and declared all functions in it as main::function.
I can use them easily in main program, but have problems if I try to use those functions as parts of condition or actions of rules...
I try to use them as "eval $str" from some Perl::PIE package, where $str is written in xml rules config file, but it seems that it is not working at all. I think I need to run them in "context of the main" program but this is obviously not happening... I've debugged code and it doesn't get into function at all. I must be missing some basic things about dealing with global variables and functions...
I have this in xml config :
<rule name="print status every 5 secs">
<condition attribute='main::new_second(5)' type="time" trigger="1">
+1</condition>
<action attribute="\n****************print status every 5 secs: New
+_Second: Weekday:$Wday Time:$Hour:$Minute:$Second Time_Now:$Time_Now
+Date:$Mday/$Month/$Year" type="print">1</action>
</rule>
and when I try to eval('main::new_second(5)') nothing happens, if I do the same from main program it works...
I'd kindly as for some help or some pointers to similar solutions ...
Thanks in advance,
regards,
Rob.