Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: 'do' read file

by scorpio17 (Abbot)
on Dec 14, 2011 at 15:10 UTC ( #943565=note: print w/replies, xml ) Need Help??

in reply to 'do' read file

In general, I think it's considered "bad practice" to put executable code into a config file. Try doing something like this instead:

#!/usr/bin/perl use strict; use Config::Auto; use Data::Dumper; my $config = Config::Auto::parse("1.spec", format => "equal"); print Dumper($config), "\n";

And change your config file ("1.spec") to something like this:

NAME = Philip AGE = 21

When you run this code, you should get this output:

$VAR1 = { 'NAME' => 'Philip', 'AGE' => '21' };

In other words, $config is a hash ref pointing to the data read from the config file.

Config::Auto is very powerful, and can handle much more complicated situations. Read more about it on CPAN.

Replies are listed 'Best First'.
Re^2: 'do' read file
by jdporter (Canon) on Dec 14, 2011 at 16:01 UTC
    In general, I think it's considered "bad practice" to put executable code into a config file.

    So don't think of it as a config file. Think of it as a module for setting some variables.

    (That said, I have nothing against Config::Auto. They should call it Config::Awesome.:-)

    I reckon we are the only monastery ever to have a dungeon stuffed with 16,000 zombies.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://943565]
[roboticus]: Maybe use a squarified tree map tool (first google hit I got: https://windirstat .net/)
[Discipulus]: LanX TreeSize used to be useful.. but if is 9mb..;=)
[pryrt]: LanX, I like NirSoft SearchMyFiles for finding large / duplicate files...
[SuicideJunkie]: Windirstat is what we use here for nagging people who use up the transfer share.

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (10)
As of 2017-09-20 16:56 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (237 votes). Check out past polls.