It reads data from $source that is
delimited by the $delimiter characters, and returns a hash reference.
The hash keys are the period-limited keywords. The input, $source,
may be either a filename (in which case the file is opened, read, and
closed), a FILEHANDLE, or a text string.
sub parse_input {
my ($delimiter,$source) = @_;
my %A = ();
my $input;
if (ref($source) eq "GLOB") { # read the entire file handle contents
# if a GLOB was passed in
$input = join("",<$source>);
} elsif ( -s $source ) { # input is coming from a filename
open(F,"< $source");
$input = join("",);
close(F);
} else { # a simple text string was passed in
$input = $source;
}
my @words = split($delimiter,$input);
for my $word (@words) {
next if ($word =~ /^\#/);
$word =~ s/^(\s+)?(.+)(\s+)?$/$2/;
my ($k,@v) = split('=',$word);
my ($t,$attr) = split('\.',$k);
my $value = join('=',@v);
if (defined($attr)) {
if ($attr =~ /e(ncrypted_)?passw(or)?d/i) {
$value = _decrypt($value);
$attr = "password";
}
$A{uc($t)}->{uc($attr)} = $value;
} else {
$A{uc($k)} = $value;
}
}
return \%A;
}

