package PDM::Parse;
use strict;

sub parse {
  my($class, $file) = @_;
  my $F = System->get_home() . "/$file";
  my @H = ();
  my ($l, $section);
  my $cnt=-1;
  if (open(O, $F)) {
    while ($l = <O>) {
      chop($l);
      next if (substr($l,0,1)  eq "#");
      if ($l =~ /^\[(\w+)\]/) {
         $section = $1;
         $cnt++;
         $H[$cnt]{_section} = $section;
      } elsif (index($l, "=") > 0) {
         my($a,$b) = split(/\s*\=\s*/, $l,2);
         $H[$cnt]{$a} = $b;
      }
    }
    close(O);
  } 

  return \@H;
}

sub file2hash {
  my($class, $file) = @_;
  open(O, $file);
  my($l, %hash);
  while ($l = <O>) {
     chop($l);
     my ($name, $val) = split(/\s*=\s*/, $l);
     $hash{$name} = $val;
  }
  close(O);
  return \%hash;
}

1;

