hd.update 832 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. # Return associative array of fields from control file $file.
  2. $vardir = $ARGV[0];
  3. sub slurp
  4. {
  5. local ($file) = @_;
  6. local (%controlinfo);
  7. local (%ci);
  8. open (CONTROL, $file) || return 1;
  9. # Get entire text of control file.
  10. undef $/; $* = 1; $_ = <CONTROL>;
  11. # Join lines.
  12. s/\n[ \t]+/ /g;
  13. # Split on fields.
  14. %controlinfo = ('PRESTUFF', split (/^(\S+):\s*/));
  15. $/ = "\n"; $* = 0;
  16. foreach $key (keys %controlinfo)
  17. {
  18. $key2 = $key; $key2 =~ y/A-Z/a-z/;
  19. chop ($controlinfo{$key}) if (/\n/);
  20. $ci{$key2} = $controlinfo{$key};
  21. }
  22. return %ci;
  23. }
  24. $file = "$vardir/methods/hd/hd.status";
  25. %info = slurp($file);
  26. open (IN, "<$info{'avail'}") || die "can't open $info{'avail'}";
  27. open (OUT, ">$vardir/available") || die "can't open $vardir/available";
  28. print OUT while (<IN>);
  29. close IN;
  30. close OUT;