Hi Chaoui05,

It looks like your config file is using array ref constructors [...] where it should be using hash ref constructors {...}. If you can change your configuration file, that would be the easiest way to fix up your configuration. Then you can use all the normal methods of accessing complex data structures, see e.g. perlreftut and "hash of hashes" in perldsc.

If you can't change the format of the file, then since the array refs appear to contain a list of key/value pairs, you can simply assign them to a hash, for example:

my %programs = @{ $config->{programs} }; for my $prog (values %programs) { my %param = @{ $prog->{parameters} }; print $param{Count_id},"\n"; }

Will print the Count_id value for each "program". One caveat is that this will silently clobber any "programs" and "parameters" with the same name. Whether that is a problem in your case depends on what the rest of your configuration file looks like.

Hope this helps,
-- Hauke D

Updated wording.


In reply to Re: Recover data from a config file to use them with Selenium::Remote::Driver by haukex
in thread Recover data from a config file to use them with Selenium::Remote::Driver by Chaoui05

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.