Thursday 15 April 2010

perl - Interpolate in YAML -


I am using Perl as my scripting language and am reading YAML config. Files There are some fields (such as memory addresses) that are often used and are related to the base area. Is it possible to launch an anchor value and it is possible to do any work on it within the YAML file? I am using YAML :: XS as a parser module in Perl.

For example, in file.cfg.yml

 % YAML 1.1 --- Base: & amp; ; Base 10001000 - reg: - abc: * base + 4 ...   

Is it possible to do any work on bin, oct, or hex values?

No, but you can sort actions as codes. If you can not control the input, the desiilizing code is actually silly idea. Take it and take it to heart.

  Use YAML :: XS qw (dump); $ YAML :: XS :: Usakode = 1; #Danger Danger OMG You are doing that you are dancing or my $ base = 10001000; My $ data = [{base = & gt; $ Base},]; Push @ {$ data}, {reg = & gt; [{ABC = & gt; Sub {$ data-> [0] {base} + 4},}]}; Print dump $ d; __END__ --- - Base: 10001000 - reg: - abc: !! Perl / code | - {$$ data [0] {'base'} + 4; }    

No comments:

Post a Comment