t-rex has asked for the wisdom of the Perl Monks concerning the following question:
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
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.rulesfile: [*rulesid_01] target_list: [*runid_01]
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: YAML parsing in perl reference decoding
by choroba (Cardinal) on Jul 04, 2016 at 06:52 UTC | |
Re: YAML parsing in perl reference decoding
by kroach (Pilgrim) on Jul 03, 2016 at 13:40 UTC | |
by t-rex (Scribe) on Jul 03, 2016 at 14:42 UTC | |
by AnomalousMonk (Archbishop) on Jul 03, 2016 at 20:15 UTC | |
by t-rex (Scribe) on Jul 04, 2016 at 05:16 UTC | |
by GotToBTru (Prior) on Jul 04, 2016 at 06:21 UTC | |
| |
Re: YAML parsing in perl reference decoding
by t-rex (Scribe) on Jul 04, 2016 at 10:34 UTC |