in reply to Recover data from a config file to use them with Selenium::Remote::Driver
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Recover data from a config file to use them with Selenium::Remote::Driver
by Chaoui05 (Scribe) on Jun 02, 2016 at 10:38 UTC | |
by haukex (Archbishop) on Jun 02, 2016 at 13:16 UTC | |
by Chaoui05 (Scribe) on Jun 03, 2016 at 07:43 UTC |