If you create the variable in the config as $::folder = 'E:\FOLDER\Test\WEB';, then it is available in the main program in the same way.

However, the bulk of the config will be inaccessible as it is declared as an anonymous hash with no name.

You could fix that with work.conf:

$::folder = 'E:\FOLDER\Test\WEB'; $::config = { license => 'kit-licence.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', ] }, ] };

Main program:

#! perl -slw use strict; use Data::Dump qw [ pp ]; do 'work.conf' or die $!; print $::folder; pp $::config;

Output:

C:\test>junk Name "main::folder" used only once: possible typo at C:\test\junk.pl l +ine 7. Name "main::config" used only once: possible typo at C:\test\junk.pl l +ine 9. E:\FOLDER\Test\WEB { license => "kit-licence.zip", programs => [ "VIKTOR DESCRIPTION PRODUCT", { name => "VIKTOR ", parameters => [ "Count_id", "06 (Viktor)", "Birth_date", 1995-04-30, "Marriage_date", 2014-05-26, "Divorce_date", 2015-03-30, "Activities_folder", "E:\\FOLDER\\Test\\WEB\\VIKTOR\\independent wo +rker", "Activities_format", "Enterprise Format (V35)", "Description_File_from", "E:\\FOLDER\\Test\\WEB\\VIKTOR\\FILE\\descript +ion.xlm", ], }, ], }

Also $main::config & $main::folder would work. Or you could go the OO route and make work.conf a proper object.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice. Not understood.

In reply to Re: Recover a path from a config file by BrowserUk
in thread Recover a path from 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.