A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.

Native Perl configuration file

Define a configuration file as a Perl package, containing hash data:

$ cat data
package d;

$a = {
    1 => 2,
    b => 'c',
};

Use this method to read the data straight into Perl:

$ perl -MData::Dumper -le'eval { require "./data"; }; print Dumper($d::a)'
$VAR1 = {
          '1' => 2,
          'b' => 'c'
        };

This avoids the need to employ a parser, as the data is already in a Perl data structure format.

NOTE: You must specify the absolute path to the data file. I found that 'data' failed, where './data' succeeded.

If you leave out the package declaration in the data file, you can access the hash using $main::a