in reply to Re: Recover a path from a config file
in thread Recover a path from a config file

I am confused about this "I can change some stuff, but not much stuff" requirement?

The code from BrowserUk works fine for me. To eliminate the "only used once" warnings, just declare $folder in main:: as an "our" variable. An "our" variable gets into the global symbol table and can be accessed by anybody with the full name without any import/export adieu. Here is a modified main program...

#! perl -slw use strict; use Data::Dump qw [ pp ]; our $folder; #to prevent "only used once" warnings our $config; do 'work.conf' or die $!; print $folder; # $folder is declared above, here in $main # not in file work.conf # since we are in main, don't need "full name" pp $::config; #can use full name here, but not necessary
work.conf as posted by browserUk:
$::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-30', Marriage_date => '2014-05-26', Divorce_date => '2015-03-30', Activities_folder => $folder.'\VIKTOR\i +ndependent worker', Activities_format => 'Enterprise Format + (V35)', Description_File_from => $folder.'\VIKTOR\F +ILE\description.xlm', ] }, ] };
works fine. Why isn't this good enough?

As an update, This back slash stuff for file names under Windows is not required. Use the forward slash. That is easier, more portable and completely allowed since I think at least Win98. The modern Window's command line is NOT DOS.

Replies are listed 'Best First'.
Re^3: Recover a path from a config file
by Chaoui05 (Scribe) on Jun 06, 2016 at 15:35 UTC

    Hi Marshall. You right.

    I finally can use a part of browserUk code in mine. A very small part. And i will use a part of haukex code too. I will explain it after.

    *****Lost in translation****TIMTOWTOI****
      From what I can see from your config file, you are using a "BAD idea". In general, I would not use executable Perl code for a simple configuration file because there are standard formats for this, see INI file. There are number of Perl modules that can parse an .INI text file. I would use one of those! I don't see anything that would prevent that?

        Yes Marshall , i thought about it. But in my case, to improve my level in Perl , i have to use as often as possible, executable Perl. Of course, some modules can do it well.
        *****Lost in translation****TIMTOWTOI****