in reply to Re: Re: How to handle Cross-platform Perl, modules, and versioning
in thread How to handle Cross-platform Perl, modules, and versioning

That won't work as-is because both BEGIN{} blocks will be executed before the if statement is even compiled.

If performance or memory is a consideration, unless you are using %Config for other things as well, you would be better off using $^O to test for the OS. It contain sthe same info as $Config{'osname'} but without the overhead of loading Config.pm.

Also, why are you putting a single scalar into an array and then unshifting the array?

This ought to come pretty close to what you are trying to do I think. (NB:untested)

BEGIN{ # UPDATE: Corrected typo pointed out my [Abigail-II] below. unshift @INC, $^O =~ m[^(?:MSWin32|solaris)$]i ? '/foo/custom/perl/lib/Custom_mods5.6.1' : '/foo/custom/perl/lib/Custom_mods5.005_03'; }

Though that is probably better coded as

(Also partially untested)

BEGIN{ use lib $^O =~ m[^(?:MSWin32|solaris)$]i ? '/foo/custom/perl/lib/Custom_mods5.6.1' : '/foo/custom/perl/lib/Custom_mods5.005_'; }

Examine what is said, not who speaks.
1) When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong.
2) The only way of discovering the limits of the possible is to venture a little way past them into the impossible
3) Any sufficiently advanced technology is indistinguishable from magic.
Arthur C. Clarke.

Replies are listed 'Best First'.
Re: How to handle Cross-platform Perl, modules, and versioning
by crenz (Priest) on Apr 15, 2003 at 22:08 UTC

    I would discourage that kind of test. Once you update the version of perl on Solaris, for example, you're screwed... I'd rather go for checking the version of perl.

    Of course, the best thing would be a clean install. See my other post.

      Makes sense to me but i don't live in the world of running perl on 11 platforms, so I had to assume that the OP knows what he's doing in that regard.

      I'd amazed--and mighty impressed--if all the differences between those 11 platforms can be differenciated by either the OP's test or that of just the version. I know that perl is highly portable, but I was sure that the real test would probably be more complicated than the example the OP supplied, and I don't have the cross-systems experince to even guess what it would really look like.

      I read the OP's code somewhat differently to you--and I don't know which of us is closer--in as mach as I took the ".../Custom_mods..." to mean that each machine/platform had a standard install, but that they wanted to share their in-house modules from specific places. Maybe that makes sense in thier environment?


      Examine what is said, not who speaks.
      1) When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong.
      2) The only way of discovering the limits of the possible is to venture a little way past them into the impossible
      3) Any sufficiently advanced technology is indistinguishable from magic.
      Arthur C. Clarke.
        see node 248145 for more info
Re: How to handle Cross-platform Perl, modules, and versioning
by Abigail-II (Bishop) on Apr 15, 2003 at 22:03 UTC
    @ENV? What's that array going to do?

    Also, there's no point in making a BEGIN block that contains just a lone use statement. A use statement is already executed as soon as it's compiled - putting a BEGIN around it isn't going to speed it up - it won't execute it before it's compiled.

    Abigail

      s/@ENV/@INC/. I said it was untested:)...corrected. Thanks.

      With regard to the use of the BEGIN block, in truth, the OP was using BEGIN{} so it didn't cross my mind to change that.


      Examine what is said, not who speaks.
      1) When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong.
      2) The only way of discovering the limits of the possible is to venture a little way past them into the impossible
      3) Any sufficiently advanced technology is indistinguishable from magic.
      Arthur C. Clarke.
Re: Re: Re: Re: How to handle Cross-platform Perl, modules, and versioning
by P0w3rK!d (Pilgrim) on Apr 16, 2003 at 14:34 UTC
    The BEGIN block was someone elses code that was never "adjusted". I like the way you did this. Thanks. I will adopt your wisdom into my code :) -P0w3rK!d