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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.