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