process.pl 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/usr/bin/perl
  2. #
  3. # Author:
  4. # Sean MacIsaac
  5. #
  6. use strict;
  7. my $full_expand = 1;
  8. my @template;
  9. my $n;
  10. if ($#ARGV != 2) {
  11. print "process.pl command_file template_file directory_prefix\n";
  12. exit ();
  13. }
  14. my $menu = "";
  15. open COMMANDS, $ARGV[0] || die "Can not open $ARGV[0]";
  16. while (<COMMANDS>) {
  17. chop;
  18. my @command = split /,/;
  19. if ($command[0] != -1) {
  20. $menu .= "\t\t";
  21. if ($command[0] == 0){
  22. $menu .= "<tr><td valign=\"top\" class=\"navi\"><a class=\"navi\"";
  23. } else {
  24. $menu .= "<tr><td valign=\"top\" class=\"subnavi\">&nbsp;&nbsp;&nbsp<a class=\"subnavi\"";
  25. }
  26. $menu .= "HREF=\"$command[2]\">$command[1]</A></td></tr>\n\n";
  27. }
  28. }
  29. close COMMANDS;
  30. open TEMPLATE, $ARGV[1] || die "Can not open $ARGV[1]";
  31. while (<TEMPLATE>) {
  32. push @template, $_;
  33. }
  34. close TEMPLATE;
  35. open COMMANDS, $ARGV[0] || die "Can not open $ARGV[0]";
  36. while (<COMMANDS>) {
  37. chop;
  38. my @command = split /,/;
  39. $n = $ARGV[2] . "/" . $command[2];
  40. open OUTPUT, ">" . $n || die "Can not create $n";
  41. my $content = "";
  42. open INPUT, $command[3] || die "Can not open $command[3]";
  43. while (<INPUT>) {
  44. $content .= $_;
  45. }
  46. close INPUT;
  47. my $line;
  48. my $temp;
  49. my $tit;
  50. my $title;
  51. $tit = $command[1];
  52. foreach $line (@template) {
  53. $temp = $line;
  54. $title = "$tit / Mono";
  55. $temp =~ s/#TITLE#/$title/;
  56. $temp =~ s/#CONTENT#/$content/;
  57. $temp =~ s/#MENU#/$menu/;
  58. print OUTPUT $temp;
  59. }
  60. close OUTPUT;
  61. }