http://qs321.pair.com?node_id=864176

targetsmart has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, I was using activeperl 5.6.1 for a long time, when I decided to try new strawberry perl 5.8.9, I faced a strange issue.

I installed strawberry perl in its default location C:\strawberry, and put the C:\strawberry\perl\bin as the first item in the path variable, and launched a new command prompt and typed perl --version; it correctly said perl 5.8.9, but the strange thing happened when I just put "use 5.8.9;" inside the perl scripts which I had. I got the below error ..

Perl v5.8.9 required--this is only v5.6.1, stopped at xyz.pl line 2. BEGIN failed--compilation aborted at xyz.pl line 2.
I don't want to disturb existing 5.6.1 but still try 5.8.9.
any help is greatly appreciated..


Vivek
-- 'I' am not the body, 'I' am the 'soul/consciousness', which has no beginning or no end, no attachment or no aversion, nothing to attain or lose.

Replies are listed 'Best First'.
Re: installing strawberry and activeperl
by syphilis (Archbishop) on Oct 08, 2010 at 10:56 UTC
    How are you running these scripts ?
    If you run them simply as script.pl, then the perl that gets invoked would be the perl that's associated with the '.pl' extension - which may be different to the perl that comes first in your path.

    If, otoh, you're running them as perl script.pl then the perl that gets invoked will be the first perl in your path ... and the question then changes to "how did you go about altering the path ?".

    Cheers,
    Rob
      "how did you go about altering the path ?".
      when I installed strawberry perl 5.8.9, it added the C:\strawberry to the end of the path variable, so I manually entered C:\strawberry.. at the beginning of the path variable using the "my computer->properties->advanced->environmental variables->system variables->path"

      ftype Perl says Perl="C:\strawberry\perl\bin\perl.exe" "%1" %* assoc .pl says .pl=Perl
      but still the use 5.8.9; spits the error.


      Vivek
      -- 'I' am not the body, 'I' am the 'soul/consciousness', which has no beginning or no end, no attachment or no aversion, nothing to attain or lose.
        What does perl -e "print $]" produce ?
        What does perl -e "use 5.8.9" produce ?
        Are you running the scripts as script.pl or as perl script.pl and does the output change if you switch from one method to the other ?

        Cheers,
        Rob
Re: installing strawberry and activeperl
by kcott (Archbishop) on Oct 08, 2010 at 11:17 UTC

    I switched from ActivePerl to Strawberry Perl too; although I'm using different perl versions to you. Here's my Windows Path:

    C:\strawberry\c\bin;C:\strawberry\c\i686-w64-mingw32\bin;C:\strawberry +\perl\site\bin;C:\strawberry\perl\bin;C:\Perl\site\bin;C:\Perl\bin;<o +ther non-perl stuff here>

    So that's Strawberry (C:\strawberry\*) at the very beginning; ActivePerl (C:\Perl\*) next; other Windows paths at the end.

    I have *.pl files associated with Strawberry perl. Perhaps you need to do that.

    I also start all my scripts with the shebang line:

    #!perl

    I have the additional complication of also running Cygwin. That shebang line lets me run one script from either environment without having to do anything special (although I'm not sure if it's actually read under Windows). In case you're interested, I'm running 5.12.0 in both.

    The Strawberry Perl site has some information about relocating Perl: "Now you can tell Strawberry Perl 5.12.0 where YOU want it to go: 64-bit machines, odd directory locations, USB sticks, etcetera.". I haven't used it and don't know if it pertains to your version; however, if you're still having difficulties, it might be of some help.

    Update: Re your ftype and assoc commands above, I get:

    C:\_\tmp>ftype Perl Perl="C:\strawberry\perl\bin\perl.exe" "%1" %* C:\_\tmp>assoc .pl .pl=Perl C:\_\tmp>

    -- Ken

      I have found that using a 'portable' version of Strawberry Perl is a good way to maintain separate installations on Windows. Just download one of the 'portable' zip files (e.g. strawberry-perl-5.10.1.2-portable.zip) and unzip it.

      Then run the 'portableshell.bat' that is in the top-level directory. This gives a command prompt that uses the 'portable' installation of strawberry...and it seems to ignore my existing (older) installation in C:\strawberry. You just have to remember to use 'portableshell.bat' to start up your command prompt. If I recall correctly, 'portableshell.bat' just adds the 'portable' version to the beginning of your existing path.

      I use this at work to share scripts with others, since I can just install this portable version on a network share.

Re: installing strawberry and activeperl
by sundialsvc4 (Abbot) on Oct 08, 2010 at 13:04 UTC

    As far as I know, Windows doesn’t use the PATH variable too much.   It might use it in the case of the command-line, but it usually seems to refer to the Registry.

    For example, see http://filext.com/faq/broken_exe_association.php, which talks about how Windows figures out what to do with .exe(!!) files.   (Nothing special about that page; it’s just the first thing that I “Googled...”)

    Windows, unfortunately, is a rather Byzantine system, and this is a classic example of why.   Even though it follows familiar Unix-like standards in many ways, the Registry is its Achilles heel.

      Yet another fallacious conclusion draw on the basis of a near complete misunderstanding of random, irrelevant information found on the web.

      The path is always used to locate an executable when a process is started, regardless of whether it is started by the command line, the shell, or another application. Unless it's name is prefixed by the full pathname, just as in *nix.

      The path is also used to locate dynamic libraries, com objects, device drivers; font libraries and a bunch of other things.

      The only time associations come into play is when the system is asked to locate an appropriate executable to process a named data file. A perl (or other interpreter) source file is just a data file for the interpreter executable.

      The associations mechanism is just a convenience to allow you to have the system find an appropriate executable to process a given data file. As such, it mirrors the function of the *nix shebang mechanism, but is more flexible because it works with any type of data file--graphics files; music files; video files; whatever.

      You cannot go stuffing a shebang line on the front of any of those file types, hence the reason linux, OS-X, and probably others, have adopted similar mechanisms based around Mime-types.

      You even misinterpreted the random page you found and linked to. In a nutshell it simply says that if you screw up configuration, things go wrong. And that's true whether that configuration is stored in Windows registry, or *nix's myriad small text files strewn about all over the file system(s). If users don't follow safe working practices (backups) when modifying configuration through either mechanism, they can break things. What's new.

      Was it worth your effort?


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

        Ouch!!   What a strangely hostile and disrespectful reply ... and in such a public place ...

        I endeavored to answer the question, nothing more or less.   I thought my reply was accurate and relevant.   Maybe it was not.   If I am wrong, then, please, just correct me.   “I stand corrected.”   If the post was taken to be Windows-bashing, that was not my intention.   The influence of the Registry values on a Windows system can be deep and unexpected.   I thought that a pitfall might apply here.   Maybe I am totally wrong.   Just correct me; don’t mock me.   Thanks.