CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate: Re: [digioleg54] I have a smal question about global variables: Edit Log



FishMonger
Veteran / Moderator

Feb 10, 2017, 12:37 PM


Views: 3318
Re: [digioleg54] I have a smal question about global variables

As I told you in your prior question, you should put these config item in a config file and use one of the many config modules on cpan to parse it.

Here's one very simple example.
env.cfg

Code
LOGDIR = /path/to/log/dir 
user = fishmonger
language = perl


test.pl

Code
#!/usr/bin/perl 

use warnings;
use strict;
use Config::General;
use Data::Dumper;

my $conf = Config::General->new("env.cfg");
my %config = $conf->getall;
print Dumper \%config;




Code
c:\test>test.pl 
$VAR1 = {
'user' => 'fishmonger',
'LOGDIR' => '/path/to/log/dir',
'language' => 'perl'
};


There are many ways to format the config file. I choose one of the simplest for tis example.


(This post was edited by FishMonger on Feb 10, 2017, 12:40 PM)


Edit Log:
Post edited by FishMonger (Veteran) on Feb 10, 2017, 12:40 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives