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

Hi all,
This may be something basic which I'm missing but.... whenever I try to use Win32, it crashes Perl. Other issues on Perlmonks and other sites deal with Win32 crashing if it is used for certain things. My problem is that it won't work at all:
#!/usr/bin/perl use Win32;

causes Perl to crash. I've uninstalled and reinestalled ActivePerl 5.8.8 build 819 and still have the problem. The error that crashes it seems to be with the ole.dll and reading through the log it seems that a bunch of methods fail: gethostname,getmultibyte,getwidechar, setlastole etc etc all fail.
any help on this would be greatly appreciated as I'm at a dead end with it.
many thanks
Des

Replies are listed 'Best First'.
Re: Win32 crashes perl
by bart (Canon) on Nov 29, 2006 at 18:30 UTC
    Do you, by any chance, have any other version of Perl installed? One that has a DLL that is more visible than the one that comes with this perl?

    Or is there any other DLL file "Win32.dll" in your path, that gets loaded instead, by accident?

Re: Win32 crashes perl
by shmem (Chancellor) on Nov 29, 2006 at 17:09 UTC
    Does "it crashes" mean it just disappears without saying "thanks for the fish" ? Or does it utter a last wish, or any other useful message you forgot to post? How (Not) To Ask A Question

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
Re: Win32 crashes perl
by CountZero (Bishop) on Nov 29, 2006 at 18:25 UTC
    Well, what can I say ... I have the same version of AS Perl on my computer and there it works (at least it does not "crash").

    On an entirely unrelated issue: why do you start your program with #!/usr/bin/perl? On a Windows system it is most unlikely that the perl-executable is to be found at that location.

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

      why do you start your program with #!/usr/bin/perl?
      There's no reason not to use the #! line. I use it in my Windows code as I sometimes will want to use that same code on a Linux box. One upside of Perl is it's portability (when you write with that in mind) - no reason not to accommodate that from the get-go.
      If you run Apache on your windows machine and you have installed Perl at C:\usr\, then Apache will find the perl executable at /usr/bin/perl. So this shebang is necessary and correct.
        I run Apache on my Windows machine. Perl is not installed at c:/usr/ and none of my scripts use the she-bang line and still it works. So it may be correct but it sure is not necessary.

        CountZero

        "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

Re: Win32 crashes perl
by xdg (Monsignor) on Nov 29, 2006 at 19:07 UTC

    Works for me on Vanilla Perl on Win32. I'd second the call to check your PATH for conflicting .dll's or even a conflicting perl. (E.g. the Win32 SVK installer installs an entire perl.exe -- bad news if that's earlier in your PATH).

    As an aside, for crashing perl on Win32, there's always this little bit of fun, too:

    > perl -te fork

    -xdg

    Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

      As an aside, for crashing perl on Win32, there's always this little bit of fun, too:

      perl -te fork
      How do you figure? Do you mean to say it literally crashes perl? It runs fine for me:
      C:\>cmd Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. C:\>perl -te fork C:\>perl -te "fork; print qq[I am $$\n]" I am 3388 I am -5532 C:\>perl -v This is perl, v5.8.3 built for MSWin32-x86-multi-thread (with 8 registered patches, see perl -V for more detail) ...

      I am wondering whether this is a joke/pun that I am not getting. Just curious...

      Update: The same code runs on my Win2K machine at home:

      C:\>cmd Microsoft Windows 2000 [Version 5.00.2195] (C) Copyright 1985-2000 Microsoft Corp. C:\>perl -v This is perl, v5.8.4 built for MSWin32-x86-multi-thread (with 3 registered patches, see perl -V for more detail) ...

        v5.8.3... v5.8.4...

        Sorry for the confusion -- this bug was introduced in v5.8.7. No one on perl5porters seems to have any idea about it. AM mentioned "Tainted fork crash on Win32", which I posted when I first discovered it.

        -xdg

        Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

        C:\>perl -te fork

        Segfaults on all my Win32 perls (that I tried it on) on Windows 2000.

        Cheers,
        <Rob>
Re: Win32 crashes perl
by talexb (Chancellor) on Nov 29, 2006 at 18:21 UTC

    I'm not that familiar with ActivePerl any more, but the first thing I'd try would be to run the tests for the Win32 module and see if they all pass. Based on that result, you can figure out your next strategy.

    Alex / talexb / Toronto

    "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

Re: Win32 crashes perl
by Anonymous Monk on Nov 30, 2006 at 11:39 UTC
    What shows in Event Viewer?