in reply to require different modules per OS?

the string eval works great but now I'm seeing this issue:
Bareword "DETACHED_PROCESS" not allowed while "strict subs" in use at +test_script.pl line 740.
this bareword is part of a win32 process but I see this error on mac because the module is never loaded. I have an os check for this method call but it still returns an error. The easy fix is to turn off strict but I don't like doing that. Any alternatives?

Replies are listed 'Best First'.
Re^2: require different modules per OS?
by ikegami (Patriarch) on Nov 18, 2009 at 16:46 UTC
    Don't omit the parens around the argument list. You can only do that when the function has previously been declared.
    DETACHED_PROCESS()
Re^2: require different modules per OS?
by almut (Canon) on Nov 18, 2009 at 17:00 UTC
    I have an os check for this method call

    You'd have to avoid that the code is even being compiled (as opposed to not being run only), for example by (again) making use of string-eval:

    use strict; eval 'printf "%d\n", DETACHED_PROCESS;' if $^O =~ /win32/i; # ok printf "%d\n", DETACHED_PROCESS if $^O =~ /win32/i; # not o +k: Bareword "DETACHED_PROCESS" not allowed...