Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I have to read a configuration file that contains lines like these ones:

VAR=/path/to/ AMB=cer DIRSKE=${VAR}${AMB} SCRIPT=${DIRSKE}/script.sh

After a search, I found that module Appconfig can be the right one. I've read its documentation more and more, but I think I don't really understand how it works (honestly, it is a bit harder to read). Consider also that I'm only a beginner in Perl. My problem is the variable named DIRSKE. Appconfig can expand the value as in a shell script, but I can't understand how do it when I have two of them in the same line.

#!/usr/bin/perl use strict; use warnings; use AppConfig qw(:expand); my $config = AppConfig->new({ CASE => 1, GLOBAL => {EXPAND => EXPAND_ALL} }); $config->define("VAR=s"); $config->define("AMB=s"); $config->define("DIRSKE=s"); # Maybe this is wrong, but what else? $config->define("SCRIPT=s"); #read configuration file $config->file("./file.conf"); #some print print "Valore VAR -> ".$config->VAR()."\n"; print "Valore AMB -> ".$config->AMB()."\n"; print "Valore DIRSKE -> ".$config->DIRSKE()."\n"; print "Valore SCRIPT -> ".$config->SCRIPT()."\n";

The output is:
Valore VAR -> /path/to/ Valore AMB -> cer Valore DIRSKE -> Valore SCRIPT -> /script.sh

I'd like to have something like:
Valore VAR -> /path/to/ Valore AMB -> cer Valore DIRSKE -> /path/to/cer Valore SCRIPT -> /path/to/cer/script.sh

Am I using the correct module?
If yes, can I have a suggestion on how to do it?

Thanks!


In reply to Appconfig module question by hveneticus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (1)
As of 2024-04-26 02:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found