in reply to Portability question: Is there something like '#ifdef' in Perl?

Yes, you can use #ifdef in Perl, in combination with the -P switch (see man perlrun). But I've never seen a serious program using it, and I can't imagine a situation where you want to use it.

If you want to use a module Win32::Foo only if the OS is Windows, do something like:

use if $^O =~ /Win32/, Win32::Foo => qw /arg1 arg2 arg3/;

Abigail

  • Comment on Re: Portability question: Is there something like '#ifdef' in Perl?
  • Download Code