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

If you want to check whether or not a particular module is available, you do that like this:
eval 'require Win32::GetShortPathName'; if ($@) { # nope, not on this system } else { # yes, go ahead with it }
Note that you must leave out the "use" for the module.

Or were you asking how to tell what platform you're on?

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

Replies are listed 'Best First'.
Re: Re: Portability question: Is there something like '#ifdef' in Perl?
by sureshr (Beadle) on Sep 29, 2003 at 16:30 UTC
    Thank you! Its just the kind of solution I was looking for, though I was planning to insert code based on ifdef doing a platform check.

    Thanks to others too, who have answered my original query!

    -sureshr