sub read_configuration_file { # Open and read configuration file specified as first passed parameter # $_[0]. Return the contents of the file as the hash array %config_param. # Lines beginning with "#" are treated as comments. It is assumed # that the indirect file contains lines as # Modified February 26, 2003. Remove leading and trailing spaces for # the key and value, but don't remove all spaces. # parameter := value # and this information is stored as # $config_param{"parameter"} = value my $filename = $_[0]; my ($parameter, $value); #print STDOUT ("#**debug, indirect filename=$filename\n"); unless (defined $filename ) { &sendmessage ($error, "Could not open configuration file", "File name not specified. Cannot continue."); exit; } unless (open CONFIG_FILE, $filename) { &sendmessage ($error, "Could not open configuration file=$filename", "Error code=$!. Cannot continue."); exit; } while () { chomp; if (m/^#/) { next;} unless ( m/\S+/ ) {next;} unless ( m/:=/ ) { &sendmessage ($warning, "No :equal sign in line of config file=$filename", "Line is=$_"); next; } # print STDOUT ("***debug, config input line=$_\n"); ($parameter, $value) = split /:=/; $parameter =~ s/^\s+//; $parameter =~ s/\s+$//; $value =~ s/^\s+//; $value =~ s/\s+$//; $config_param{$parameter} = $value; # print STDOUT ("#**debug, config_param{$parameter}=", # $config_param{$parameter}, "\n"); } close CONFIG_FILE; } 1;