##########################################################################
#
# routine: ores_pkg.pl
#
# purpose: retrieves keyword/value map from a process resource file
#
# Input:   inpFileName - input filename
#
# Returns: map of keyword/value pairs
#
# modification history:
#
#   date    opr     who     reason
# -------- -----  --------  --------------------------------------
# 07/02/12 71663  Heller    first version
#
##########################################################################
  use strict;

  sub Resource {
      my ($inpFileName) = @_;
      my %kywdValue=();
      open INFILE, "<$inpFileName";
      while ( my $line = <INFILE> ) {

         chop $line;              # Remove trailing newline
         # Skip lines that aren't in the form 'keyword = value'
         next if $line !~ /[\w\-]+\s*=/;
         

         # Get the keyword and value, removing leading and trailing spaces
         my ( $kywd, $value ) = split( /= /, $line, 2 );
         $kywd =~ s/\s+$//;

         # Strip off spaces and quotes
         $value =~ s/''/"/g;              # Change '' to " (for next step)
         $value =~ s/'([^']+)'.*/$1/;     # Get things between single quotes
         $value =~ s/"/'/g;               # Put single quote back
         $value =~ s/ \! .*$//;           # Strip off comments starting with /
         $value =~ s/^\s+//;              # Remove leading spaces
         $value =~ s/\s+$//;              # Remove trailing spaces
         # Empty values should be replaces with ~ to avoid a perl false ('').
         $value = '~' if $value eq '';
         #print "$kywd = $value \n";
         $kywdValue{$kywd} = $value;
      }
      # Close the input file
      close INFILE;
      return (\%kywdValue);

  }
1;
