Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: Config::Std multi-part problem

by TheDamian (Priest)
on Dec 13, 2005 at 21:49 UTC ( #516442=note: print w/replies, xml ) Need Help??

in reply to Config::Std multi-part problem

If you want to convert a single-valued entry into a multi-valued entry, you need to convert the scalar to an array . Like so:
use Config::Std; read_config 'test.cfg' => my %config; print $config{"MYSECTION"}{"element"} . "\n"; $config{"MYSECTION"}{"element"} = [ $config{"MYSECTION"}{"element"}, "test2", ]; write_config %config;

Replies are listed 'Best First'.
Re^2: Config::Std multi-part problem
by carcassonne (Pilgrim) on Dec 14, 2005 at 13:31 UTC
    Thanks, this works fine.

    I now also use Contextual::Return to see if the value is a scalar in the first place:

    print "This is a scalar\n" if (SCALAR { $config{"MYSECTION"}{"element"} });

    If I had the time, I could look into Contextual::Return to see what code is SCALAR, and extract only that, but I see no problem so far in including the whole module.

    I've noticed a blank entry in %config. Please see the new thread I created for that subject.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://516442]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2022-05-23 12:18 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (82 votes). Check out past polls.