in reply to Re^3: Installing Sybase::DBlib problems
in thread Hello Word\n

That's not the way to do it.  use statements are being executed at compile time, and the condition is being evaluated at runtime.

That's what the if module is for... (or use require instead of use)

Replies are listed 'Best First'.
Re^5: Installing Sybase::DBlib problems
by wilko (Acolyte) on Nov 20, 2008 at 13:46 UTC
    Thanks almut and all Monks who offered their wisdom!

    I didn't know about the 'if' module

    use lib './lib'; use if $ARGV[0] eq "recv", Sybase::DBlib;
    Regards
    John

      Just two more things to be aware of.  It's usually better to specify the module name as a string ("Sybase::DBlib")1, otherwise you'd get a "Bareword ... not allowed" error when running under "use strict".

      Second, the "use if ..." condition is tested at compile time. In this particular case with $ARGV[0] this is not a problem, because the variable is initialized early on. But if you use some other variable, you might need to wrap its assigment in a BEGIN {...} block...

      ___

      1 only with "use if", that is — with plain "use", in contrast, a bareword is needed.