hello monks, I am parsing a yaml file and its very complex taking reference, has anyone tried it before ,pls help me with this, i have read much documentation but to no use.

#my main.pl where i parse the yaml file $input_file = $ARGV[0]; print "Input File = $input_file\n"; # parse the yaml file $yaml_input = YAML::XS::LoadFile("$input_file"); #these are my parse functions : sub parse_yaml_run_tgt($) { my ($yaml_input) = @_; $run_target_platforms = $yaml_input->{run_target_platforms}; @run_target_id = (); @run_target_controls = (); @run_target_con_info = (); my $i = 0; for my $run_index (@$run_target_platforms) { $run_target_id[$i] = $run_index->{run_target_id}; $run_target_controls[$i] = $run_target_id[$i]->{target_control +s}; $run_target_types[$i] = $run_target_controls[$i]->{run_target_ +type}; $run_target_active[$i] = $run_target_controls[$i]->{run_target +_active}; $run_target_con_info[$i] = $run_target_id[$i]->{target_connect +ion_info}; $run_target_hostname[$i] = $run_target_con_info[$i]->{run_targ +et_hostname}; $i++; } } sub parse_yaml_standalone($) { my ($yaml_input) = @_; $standalone_exec = $yaml_input->{standalone_execution}; $utpsm_exec = $standalone_exec->{utpsm_executable}; $se_hostname = $utpsm_exec->{hostname}; $se_tgt_list = $standalone_exec->{target_list}; $se_rulesfile = $standalone_exec->{rulesfile}; } #and this is my yaml file : ################################################ # Input file for uTPSM regression test control # ################################################ test_control: standalone_execution: yes code_checkout: no #yes/no rules_file: - rules_file_id: &rulesid_01 name: hostname: - rules_file_id: &rulesid_02 name: run_target_platforms: - run_target_id: &runid_01 target_controls: run_target_type: simulator #simulator, emulator , hardware run_target_active: yes target_connection_info: standalone_execution: utpsm_executable: hostname: rulesfile: [*rulesid_01] target_list: [*runid_01] ...

i have parsed everything except for reference

rulesfile: [*rulesid_01] target_list: [*runid_01]
i know many of the fields won't make much sense asking the question but i have edited coz these files are very huge , if still its not very readable pls let me know i will further reduce the number of fields. pls help to solve the reference, i want to know how to write a variable which will be pointing to my run target parameter from my standalone execution.


In reply to YAML parsing in perl reference decoding by t-rex

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.