# Return associative array of fields from control file $file.
$vardir = $ARGV[0];
sub slurp
{
  local ($file) = @_;
  local (%controlinfo);
  local (%ci);

  open (CONTROL, $file) || return 1;

  # Get entire text of control file.
  undef $/; $* = 1; $_ = <CONTROL>;

  # Join lines.
  s/\n[ \t]+/ /g;

  # Split on fields.
  %controlinfo = ('PRESTUFF', split (/^(\S+):\s*/));

  $/ = "\n"; $* = 0;
  foreach $key (keys %controlinfo)
    {
      $key2 = $key; $key2 =~ y/A-Z/a-z/;
      chop ($controlinfo{$key}) if (/\n/);
      $ci{$key2} = $controlinfo{$key};
    }

  return %ci;
}

$file = "$vardir/methods/hd/hd.status";
%info = slurp($file);
open (IN, "<$info{'avail'}") || die "can't open $info{'avail'}";
open (OUT, ">$vardir/available") || die "can't open $vardir/available";
print OUT while (<IN>);
close IN;
close OUT;

