in reply to Re^6: How to call particular parameter from another configuration file in perl
in thread How to call particular parameter from another configuration file in perl
./CA.pl
#!/usr/bin/perl use warnings; use strict; use Config::Simple; my $confdir = $ENV{CFG_DIR}; my $conffile = 'LED.cfg'; my $pillar = 'dev'; my $led_cfg = "$confdir/$conffile"; 'Config::Simple'->import_from($led_cfg, \ my %Config); my $ap_id = $Config{ $pillar . '_lcd.AppID' }; print "$ap_id";
./cfg/LED.cfg
[dev_lcd] AppID=APTC_RDFG User=AB12345 [tst_lcd] AppID=APTC_RERF User=AB45678 [pro_lcd] AppID=APTC_RDHF User=AB98765
./main.pl
#!/usr/bin/perl use warnings; use strict; my $pwd = qx{./CA.pl}; print "$pwd\n";
Now, when I run
CFG_DIR=./cfg ./main.pl
I'm getting the expected output:
APTC_RDFG
How is your scenario different?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: How to call particular parameter from another configuration file in perl
by Prakee (Initiate) on Jun 17, 2021 at 08:00 UTC | |
by Corion (Patriarch) on Jun 17, 2021 at 08:03 UTC |