Always somthing new.

Well I was just cleaning up a few things in some very old code this AM and I noticed this

Use Config;

die "chown not available!" unless $Config{"chown"};

and a number of similar lines checking for what I though would be 'core' functions, (like I said this was an old piece of code).

What caught my eye was the 'Config' mod never run into that one before so I had a quick read. I quickly determined that all perl programmers will use this module in onlyu one of three ways

  1. Never have a need for or even look at it or
  2. Use all the time and sleep more soudly because of it or
  3. Have a look at, play with until you corrupt your perl and then never play with again

Well I defiantly a solid '3' so I spend a few mins playing around and I tried this

use Config;
foreach (sort keys(%Config)){
	print "$_ : $Config{$_}\n"
This gave me this big ass list;

Author : 
CONFIG : true
Date : $Date
Header : 
Id : $Id
Locker : 
Log : $Log
zcat : 
zip : zip

Of course there is lots of interesting stuff to be found in this list. What I should of done was read a little further along before I wrote the above as all I really needed to to was

print Config::config_sh();

and got the same result. Oh well a few extra minutes of coding never hurt anyone.

Well I did like'

print Config::myconfig()

as that is the same as a 'perl -V' with out the path and lib info. I could see that one coming in handy someday as I would be good to check a few things when writing tests so one can skip or run separate tests.

The real serendipitous one for me today was that I could get info on the 'sig_name' and 'sig_number' of the installed perl from my big ass list. You see I have just started working on a module that will be making use of a little 'POSIX' programming. One thing I know is I will have to get it working in both Linux and Windows so this may come in handy when I go to write up some tests.

Well to the sys-admin programmer or those doing large scale configuration I could really see the use of this module and I guess it has been around forever I just never ran across it directly.

Always learning something new even in my old age.


'perldoc Config' will give you more information (than you'll probably ever need) :)

Config has its uses. The two things I've used it most for are: determining the system's C compiler ($Config{cc}) and checking if Perl has been built with thread support ($Config{useithreads}).

`$Config{osname}` is quite valuable as well of course (especially in code that would otherwise assume it's running on some form of unix).

Leave a comment

About byterock

user-pic Long time Perl guy, a few CPAN mods allot of work on DBD::Oracle and a few YAPC presentations