home *** CD-ROM | disk | FTP | other *** search
/ APDL Public Domain 1 / APDL_PD1A.iso / program / language / perl / Test / T / Comp / Cpp < prev    next >
Encoding:
Text File  |  1990-11-13  |  633 b   |  38 lines

  1. #!./perl -P
  2.  
  3. # $Header: comp.cpp,v 3.0.1.2 90/11/10 02:10:17 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,">Tmp.Cpp") || die "Can't open temp perl file.";
  19.  
  20. ($prog = <<'END') =~ s/X//g;
  21. X$ok = "not ok 3\n";
  22. X#include "Tmp.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,">Tmp.Inc") || (die "Can't open temp include file.");
  32. print TRY '#define OK "ok 3\n"' . "\n";
  33. close TRY;
  34.  
  35. $x = `^.perl -P Tmp.Cpp`;
  36. print $x;
  37. unlink 'Tmp.Cpp', 'Tmp.Inc';
  38.