home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / perl / os2perl / cpp.t < prev    next >
Text File  |  1991-06-16  |  719b  |  40 lines

  1. #!./perl -P
  2.  
  3. # $Header: cpp.t,v 4.0 91/03/20 01:50:05 lwall Locked $
  4.  
  5. print "1..3\n";
  6.  
  7. #this is a comment
  8. #define MESS "ok 1\n"
  9. print MESS;
  10.  
  11. #If you capitalize, it's a comment.
  12. #ifdef MESS
  13.     print "ok 2\n";
  14. #else
  15.     print "not ok 2\n";
  16. #endif
  17.  
  18. open(TRY,">Comp.cpp.tmp") || die "Can't open temp perl file.";
  19.  
  20. ($prog = <<'END') =~ s/X//g;
  21. X$ok = "not ok 3\n";
  22. X#include "Comp.cpp.inc"
  23. X#ifdef OK
  24. X$ok = OK;
  25. X#endif
  26. Xprint $ok;
  27. END
  28. print TRY $prog;
  29. close TRY;
  30.  
  31. open(TRY,">Comp.cpp.inc") || (die "Can't open temp include file.");
  32. print TRY '#define OK "ok 3\n"' . "\n";
  33. close TRY;
  34.  
  35. $pwd=`cd`;
  36. $pwd =~ s/\n//;
  37. $x = `perl -P Comp.cpp.tmp`;
  38. print $x;
  39. unlink "Comp.cpp.tmp", "Comp.cpp.inc";
  40.