• Home
  • Services
    • Consultancy
    • Custom Software Solutions
    • Systems Adminsitration
    • SCM
      • Clearcase
      • Multisite
      • Clearquest
      • Release Managment
      • CVS
    • Web Applications
    • Customers
  • Publications
    • Clearcase
      • Triggers
      • Open Source Builds
    • Clearquest
      • Clearquest Daemon
      • DB Conversions
    • Systems Admin
      • Unix/Linux
      • Windows
    • Scripting
      • Perl
      • PHP
      • ECRDig
  • About
    • Services
    • Our People
    • Our Philosophy
    • Contact Us
 

ClearSCM Inc.

You are viewing an unstyled version of this page. Either your browser does not support Cascading Style Sheets (CSS) or CSS styling has been disabled.

NAME GetConfig.pm

Simple config file parsing

VERSION

Author

Andrew DeFaria <Andrew@DeFaria.com>

Revision

Revision 1.11

Created

Tue Feb 14 11:03:18 PST 2006

Modified

Modifed 2008/09/22 15:41:27

SYNOPSIS

Parse config files.

 # Comment lines are skipped - white space is eliminated...
 app:                   MyApp
 nbr_iterrations:       10
 major_version:         1
 release:               2
 version:               $major_version.$release

 my %opts = GetConfig "myconfig.cfg";
 print "Application Name:\t" . $opts {app}              . "(" . $opts {version} . )\n";
 print "Iterrations:\t\t"    . $opts {nbr_iterrations}  . "\n";

yields

 Application Name:      MyApp (1.2)
 Iterrations:           10

DESCRIPTION

This module is a simple interface to reading config files. Config file format is roughly like .XDefaults format - <name>:<value> pairs. A hash of the name/value pairs are returned. Variable interpolation is supported such that env(1) variables will be interpolated as well as previously defined values. Thus:

 temp_files: tmp
 temp_dir:   $HOME/$temp_files
 temp_dir2:  $HOME/$foo/$temp_files

would return:

 $conf{temp_files} => "tmp"
 $conf{temp_dir}   => "~/tmp"
 $conf{temp_dir2}  => "~/$foo/tmp"

In other word, $HOME would be expanded because it's set in your environment and $temp_files would be expanded because you set it in the first line. Finally $foo would not be expanded because it was not set in the first place. This is useful if other processing wants to provide further interpolation.


ROUTINES

The following routines are exported:

GetConfig ($conf)

Reads $filename looking for .XDefaults style name/value pairs and returns a hash.

Parameters:

$conf

Name of configuration file

Returns:

Hash of name/value pairs

DEPENDENCIES

Display

INCOMPATABILITIES

None yet...

BUGS AND LIMITATIONS

There are no known bugs in this module.

Please report problems to Andrew DeFaria (Andrew@DeFaria.com)

AUTHOR

Andrew DeFaria (Andrew@DeFaria.com)

LICENSE AND COPYRIGHT

This Perl Module is freely available; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This Perl Module is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License (http://www.gnu.org/copyleft/gpl.html) for more details.

You should have received a copy of the GNU General Public License along with this Perl Module; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. reserved.