www.pudn.com > sphinx_recipe.zip > GetFromConfig.pl


#!/usr/bin/perl

# Given a name/value config file, return one specific
# entry from the file.
#
# Copyright 2006 by Keith Vertanen
#

use strict;

if ( @ARGV < 2 )
{
    print "$0  \n";
    exit(1);
}

my $line;
my $i;
my $find;
my $configFile;
my @chunks;


($configFile, $find) = @ARGV;

open(IN, $configFile);
while ($line = )
{
    $line =~ s/[\n\r]//g;

    # Skip any comment lines
    if (index($line, "\#") != 0)
    {
	@chunks = split(/\s{1,}/, $line);
	if (@chunks == 2)
	{
	    if (index($chunks[0], $find) != -1)
	    {
		print $chunks[1];
	    }
	}
    }
}
close(IN);