home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-perl-addon-1.4.9-installer.exe / UseBytes.pm < prev    next >
Encoding:
Perl POD Document  |  2003-11-21  |  1.2 KB  |  39 lines

  1. # $Id: UseBytes.pm,v 1.3 2003/11/21 05:08:26 rcaputo Exp $
  2.  
  3. package POE::Macro::UseBytes;
  4. use POE::Preprocessor;
  5.  
  6. use vars qw($VERSION);
  7. $VERSION = do {my@r=(q$Revision: 1.3 $=~/\d+/g);sprintf"%d."."%04d"x$#r,@r};
  8.  
  9. # Make the "use_bytes" macro evaluate to C<use bytes;> in Perl on or
  10. # after 5.005_55.  Systems before then don't have the option, so the
  11. # macro evaluates to emptiness.  This macro may go away if POE stops
  12. # supporting old Perl versions.
  13.  
  14. # Macro definitions can't be indented, so this looks ugly.
  15.  
  16. # The "# include" modifier causes the conditional to be evaluated at
  17. # compile time.  This turns regular if/else logic into the moral
  18. # equivalent of the C preprocessor's #if/#else.
  19.  
  20. # Because the conditionals are evaluated at compile time, it's
  21. # imperative that the things they test be defined.  The BEGIN block
  22. # makes sure HAS_BYTES is defined before the tests are executed.
  23.  
  24. BEGIN { eval "use bytes; sub HAS_BYTES () { 1 }";
  25.         eval "sub HAS_BYTES () { 0 }" if $@;
  26.       };
  27.  
  28. if (HAS_BYTES) { # include
  29. macro use_bytes {
  30.   use bytes;
  31. }
  32. } else { # include
  33. macro use_bytes {
  34. }
  35. } # include
  36.  
  37. #------------------------------------------------------------------------------
  38. 1;
  39.