Hi Monks !

I have to request your wisdom again.

I have a config.file to do some tests and i would like to get some values from this one also.

Here my config.file :

my $folder = 'E:\FOLDER\Test\WEB'; { license => [ 'kit-licence.zip', 'kit-work.zip' ], programs => [ #template society =>\%program_work 'VIKTOR DESCRIPTION PRODUCT' => { name => 'VIKTOR ', parameters => [ Count_id => '06 ( +Viktor)', Birth_date => '1995-04-3 +0', Marriage_date => '2014-05-26', Divorce_date => '2015-03-30', Activities_folder => $folder. +'\VIKTOR\independent worker', Activities_format => 'Enterpr +ise Format (V35)', Description_File_from => $folder.'\VI +KTOR\FILE\description.xlm', ] }, 'OLIVER NEW OBJECT' => { name => 'OLIVER ', parameters => [ Count_id => '06 ( +oliver)', Birth_date => '1990-04-3 +0', Marriage_date => '2011-03-26', Divorce_date => '2014-01-30', Activities_folder => $folder. +'\OLIVER\independent worker', Activities_format => 'Enterpr +ise Format (V35)', Description_File_from => $folder.'\OL +IVER\FILE\description.xlm', ] }, ] };

My file test is following:

#test.pl use Modern::Perl; my $config = do 'work.conf'; use Data::Dumper; say Dumper( $config );
To get parameters in Programs for Viktor for example, i can do this :
%programs = @{ $config->{programs} }; for my $prog (values %programs) { my %param = @{ $prog->{parameters} }; for my $name (sort keys %param){ print $name, ': ', $param{$name},"\n"; } }

But in my case, i want to be able to get parameters for every user. Here it's just for Viktor. I would like to get them for Oliver or for an other user. For that, and to differentiate all users, i have to use the "template society" which is the name to diffenciate every users . For example, for Viktor, it's :"VIKTOR DESCRIPTION PRODUCT".For Oliver :"OLIVER NEW OBJECT"..

How can i do that ?

Same thing for "License":

license => [ 'kit-licence.zip', 'kit-work.zip' ], programs => [..
I would like to get the license by name of each one. For example, 'kit-license.zip'..

And not by "hard coding" like that:

use File::Spec::Functions qw/catfile/; my $filename = catfile($::svn, ${$config->{license}}[0]); my $filename1 = catfile($::svn, ${$config->{license}}[1]);
Perhaps in a loop, but i didn't find .

Many thanks in advance for help !!

PS : Don't ask me why they are all divorced. I really don't know.

*****Lost in translation****TIMTOWTOI****

In reply to Loops for Hash in a config.file 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.