Hello Monks, I am facing a code problem , here the file 1 is yaml file whihc i parse and get a handle to it from where i have extracted the parameters and use it for some logic and further processing.

standalone_execution: - utpsm_executable: &seid_01 name: tpsm_BE rulesfile: [*rulesid_02,*rulesid_02,*rulesid_01] target_list: [*runid_01,*runid_03] - utpsm_executable: &seid_02 name: tpsm_LE rulesfile: [*rulesid_01,*rulesid_01] target_list: [*runid_02,*runid_01]

here the rulesid_01, runid_01... these are references in yaml file. this is how take the parameters from the yaml file

for my $seindex (@$standalone_exec) { $se_exec_name[$k] = $utpsm_exec[$k]->{name}; $se_tgt_list[$k] = $utpsm_exec[$k]->{target_list}; $se_rulesfile[$k] = $utpsm_exec[$k]->{rulesfile}; #$temp = $se_rulesfile[$k][0]; #$temp2 = $temp->{name}; for my $rindex (@{$se_rulesfile[$k]}) { $se_rules_name[$j] = $rindex->{name}; $se_rules_hostname[$j] = $rindex->{hostname}; $se_rules_path[$j] = $rindex->{path}; $j++; } for my $run_index (@{$se_tgt_list[$k]}) { $se_run_target_controls[$i] = $run_index->{target_controls +}; $se_run_target_types[$i] = $se_run_target_controls[$i]->{r +un_target_type}; $se_run_target_active[$i] = $se_run_target_controls[$i]->{ +run_target_active}; # print "se run wala : $i++; } #print "$se_run_target_username[0]\n"; $k++; }

now i want to have such logic that : for every runid all the rulesid should run ... so basically i want for element in targetlist array i use each element in rules file array in rules file.... so i write this code :

my $i = 0; my $j = 0; my $k =0; foreach my $se_index (@{$Yaml_Lib::standalone_exec}) { foreach my $se_runid (@{$Yaml_Lib::se_tgt_list[$i]}) { print " run target : $Yaml_Lib::se_run_target_username +[$j]\n"; foreach my $rindex ( @{$Yaml_Lib::se_rulesfile[1]} ) { print "rules index = $rindex\n"; print "$Yaml_Lib::se_rules_name[$k]\n"; $k++; } $j++; } $i++; }

when i take the loops separately that means for target list and rules file i get the elements individually, but my purpose is to make the pone element in target list to run for all elements in rules file.Please let me know what is wrong with this code


In reply to array of array member access 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.