http://qs1969.pair.com?node_id=1058481

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

I've got Perl 5 and GNU/Linux experience, nearly zero experience on MS Windows, and need to get some scripts and tools (ex. cron, scp, tar, gzip, Perl) running on a Windows server. I'm hoping to get some guidance here about what I need to install to make this Windows box act at least somewhat like a standard *nix server.

So, perhaps some direct questions will help:

Should I install cygwin? I've done so on a test laptop (running Windows 7, not Windows Server), and it provides a familiar bash shell (so I've got that going for me, which is nice). Cygwin seems to have the regular unixy tools I require, and even comes with Perl 5.14.

Can I install and use cpanm with the Perl that comes with cygwin? I'd much rather use cpanm than manually build/install packages.

I've heard of two other ways to get Perl for Windows: Strawberry Perl and ActivePerl. Would you recommend one of those instead of the one that comes with cygwin? And if so, will installing it conflict with cygwin? Will I be able to shell out to tar and gzip and friends from that other Perl?

Any other tips for dealing with Perl on Windows gratefully accepted. Thanks!

Replies are listed 'Best First'.
Re: Newb guidance for Perl on MS Windows: Cygwin, Strawberry, ActivePerl?
by dasgar (Priest) on Oct 16, 2013 at 16:53 UTC

    I haven't tried installing multiple versions/distros of Perl on a system, so I can't offer any tips or pointers on that topic.

    Although I have to have Cygwin on some systems at work, I haven't installed Cygwin on my personal systems and haven't done much with Cygwin's Perl.

    Strawberry Perl is going to be closer to the "Perl on Linux" experience than ActivePerl - at least it will be immediately after install. Both can use cpan, but Strawberry Perl (32-bit) already comes with the compiler and other needed tools for compiling and installing modules from cpan. ActivePerl can't compile modules straight out of the box, but you can use the PPM utility to install the needed items from ActiveState's repository.

    Also, Strawberry Perl offers a portable version of their distribution that doesn't "install" anything. Instead, you run a batch file that opens a new command prompt and sets the environment variables of that command prompt to point to the needed folders to use portable Strawberry Perl. This can be put onto a USB thumb stick drive so that you can run Perl from that USB drive on other Windows systems - even if they don't have Perl installed.

    Another alternative is DWIM Perl, which is Strawberry Perl 15.4.2.1 RC (32-bit) plus a bunch of other modules installed and includes Padre.

    I haven't used it myself, but another popular distribution for Windows is Citrus Perl. The folks behind Citrus Perl also make the Cava Packager utility that can bundle your Perl script into a stand-alone executable.

    As for which to use, I think that's a personal choice. I started out using ActivePerl. Lately, I personally have been using Strawberry Perl and DWIM Perl. It might be a good idea to try a few of these out to see which one you're more comfortable with.

    The above information is based on my personal experience. Good luck with deciding on which distribution to use.

      Although I have to have Cygwin on some systems at work, I haven't installed Cygwin on my personal systems and haven't done much with Cygwin's Perl.

      So, on your personal systems, do you use that terminal program that comes with Windows? No bash? And where do you get the common command-line tools (ls, cp, mv, man, etc.)?

      Sorry to pepper you with questions. I just don't see how it could possibly work to not have a regular shell within which to work (together with the usual GNU tools available).

        You will find that Powershell is a decent terminal on Win7 - and already recognizes some of the more *nix style commands like ls and such

        fwiw, I run ActivePerl on Windows, and use Powershell as my go-to terminal

        where do you get the common command-line tools (ls, cp, mv, man, etc.)?

        If you install msysgit, one of the options is to make its suite of tools available generally (i.e. to put them into your path). There is a broader set of apps common to *nix from GnuWin32 or UnxUtils.

        But I use cmd.exe for a command prompt, when I'm not managing git. There are other shells around, but more systems to deal with than I have time or permission to customize.

Re: Newb guidance for Perl on MS Windows: Cygwin, Strawberry, ActivePerl?
by vsespb (Chaplain) on Oct 16, 2013 at 17:17 UTC
    If you have code which rely on POSIX bahviour (fork, system calls), cygwin might be the only choice.

    Otherwise native Win32 perl is probably better.. Because it's native to Win32. And perl code authors do care more about Win32 than Cygwin

    Or you can try both.. I find myself missing linux tools when I am on Windows (actually I migrated from Win to Linux that way, with cygwin in the middle)
      If you have code which rely on POSIX bahviour (fork, system calls), cygwin might be the only choice.

      Well, I just need Perl for some scripting; using tar and scp mostly — and I'd assumed I'd shell out to those, which is why I figured I'd need cygwin installed. I also need cron or a cron-like facility to run it.

      Otherwise native Win32 perl is probably better.. Because it's native to Win32. And perl code authors do care more about Win32 than Cygwin.

      Oh, really? Interesting. I'd figured it would be the other way round. Cygwin feels like a home away from home (well, after 5 minutes of using it).

      Do you know if I can use cpanm with cygwin's Perl?

      Does cpanm come with Strawberry Perl?

      Thanks.

        For scp, I recommend using PuTTY. You'll have to use the name "pscp" instead of "scp", but it works quite well.

        For tar etc. I normally use UnxUtils, but there are alternatives.

Re: Newb guidance for Perl on MS Windows: Cygwin, Strawberry, ActivePerl?
by ww (Archbishop) on Oct 16, 2013 at 20:21 UTC
    Whatever you eventually decide, don't mess with the system Perl.
    Give yourself a clean install of whichever Perl you chose... and in its own dir.

    Turning to your followup, "Well, I just need Perl for some scripting; using tar and scp mostly — and I'd assumed I'd shell out to those, which is why I figured I'd need cygwin installed. I also need cron or a cron-like facility to run it.":

    Use Perl's native capabilities. In many cases, that will be easier (after a short learning curve on the Perl analogs) than constantly shelling out (and trying to capture returns, errors, and so on); will avoid shell-quoting issues, and will sometimes even run faster.

    And as to vsespb's observation that "And perl code authors do care more about Win32 than Cygwin".... maybe! ;-) But your clientele/target audience is what matters here, anyway.

    And, yes, there are many other Perl distros: Perlbrew, Citrus Perl, DWIM Perl and many more....

    If I've misconstrued your question or the logic needed to answer it, I offer my apologies to all those electrons which were inconvenienced by the creation of this post.
      Whatever you eventually decide, don't mess with the system Perl.

      Are you referring to Cygwin's Perl when you say "system Perl"? Windows does not natively come with any version/distribution of Perl. If you want Perl on Windows, you have to download/build it and install it.

      Whatever you eventually decide, don't mess with the system Perl. Give yourself a clean install of whichever Perl you chose... and in its own dir.

      I'm guessing that you're referring to the perl in c:/cygwin64/bin as the "system perl" (the cygwin system). (Please let me know if that's incorrect.)

Re: Newb guidance for Perl on MS Windows: Cygwin, Strawberry, ActivePerl?
by VinsWorldcom (Prior) on Oct 16, 2013 at 17:48 UTC

    I use Strawberry Perl and http://gnuwin32.sourceforge.net/ for all my *nix utilities on Windows. They live in C:\usr\bin and that's the first directory in my %PATH%.

      I'm going to second this one. Strawberry has some more of the more problematic modules to build (like XML::LibXML) already built. There is another package on sourcforce called GetGnuWin32 which makes grabbing the whole GNU tool chain easy. You might have to create a few quick and dirty batch file aliases or rename a few exe files that conflict with builtins (find.exe -> gfind.exe)

      Source: Perl on windows at work, Linux at home

Re: Newb guidance for Perl on MS Windows: Cygwin, Strawberry, ActivePerl?
by jellisii2 (Hermit) on Oct 16, 2013 at 18:00 UTC

    I've been using ActiveState on Windows for quite some time at $work. I've found it has most of what I need to get work done, and leaves me in a good position in the unlikely event I need support that it's just a phonecall and credit card away. CPAN does work, but I never use it, as PPM has everything I need currently.

    Like others, I can't speak to how multiple different versions of perl will play on the same system.

    Cygwin is a nice tool, if you can get it to behave the way you wish. I haven't figured out a way to make it dovetail into the environment as well as I'd like yet, but I will also admit that I haven't taken the time to do so. The only potential problem I see with cygwin is the possibility to have to have it installed on every machine you want to port your code over to. I'm unclear if PAR::Packer plays nicely on it.

Re: Newb guidance for Perl on MS Windows: Cygwin, Strawberry, ActivePerl?
by mtmcc (Hermit) on Oct 16, 2013 at 20:44 UTC
    For what it's worth, when I've had to use perl on windows, I've used strawberry perl, without any problems. If it's good enough for Larry Wall, it's good enough for me, and I've found this to be true in practice.

    For my money, strawberry perl is closer to *nix perl, and cpan(m) has never given me any problems there. While I don't have a lot of experience with activestate perl (and I trust that I will be quickly corrected if I'm wrong), the ppm of activestate occasionally doesn't implement cpan modules as well or as completely as strawberry perl. But then again, that's just occasionally.

    On balance, strawberry perl gets my vote.

      The Strawberry Perl folks took the approach of providing the compiler and other tools needed to build Perl modules. The idea is that if you're familiar with using Perl and building/installing Perl modules in a *nix environment, you would be able to do mostly the same thing on Windows.

      ActiveState took a different approach with their ActivePerl. Windows does not natively come with any C/C++ compilers like many of the *nix type operating systems do. So their approach was to have a repository of pre-built modules that are compatible with ActivePerl. They maintain a separate repository for each version of ActivePerl. The idea is that you don't have to have a compiler (and other related tools) in order to install Perl modules. If the module exists in their PPM repository, then you have a "guarantee" that you can install and use that module.

      In addition to the PPM utility, ActivePerl can use cpan. However, ActiveState does not bundle in a compiler and make utility. So after install, a user can only install pure Perl modules from cpan. For 32-bit versions of ActivePerl, a user can install MinGW and dmake from ActiveState's repository, which would allow for installation of modules from cpan that need to be compiled (such as XS modules). (There's more challenges to get a proper compiler and make utility with 64-bit versions of ActivePerl - especially if you're trying to use the pp utility from PAR::Packer to create stand-alone executables, but I'm not familiar with those details.)

      In the end, it's just basically two approaches to deal with the issue of no C/C++ compilers (and related tools) being natively available in Windows.

      With ActiveState's approach, I personally like the "guarantee" that PPM modules can be installed and used without issues, but the price is that you might not have PPMs of the latest version of modules. With Strawberry Perl's approach, I personally like being able to install the latest version of modules directly from cpan, but the price there is that I may need to debug install issues and/or do extra work to find the work-around solution.

Re: Newb guidance for Perl on MS Windows: Cygwin, Strawberry, ActivePerl?
by Anonymous Monk on Oct 17, 2013 at 02:09 UTC
    While I do like cygwin in general, I don't like to use it's perl for any heavy lifting. File name translations and dependence on the cygwin environment make it's value outside the cygwin shell limited.

    For General use I find Strawberry perl very useful & use it at home.

    At work, I have a subscription to Activestate's PDK, giving me access to the Perltray tool. Also Activestate Perl comes with ISAPI bindings in case you need to play nice with an IIS server.

    TJD

Re: Newb guidance for Perl on MS Windows: Cygwin, Strawberry, ActivePerl?
by wjw (Priest) on Oct 17, 2013 at 02:07 UTC
    My experience has been that cygwin is good, ActiveState is ok, and other flavors of Perl are fine if you like them.

    Perl on a *nix system just works. Perl built for windows systems work well on windows.

    However, when I have made the effort to achieve a mix of *nix like functionality along with excellent Perl performance on top of windows, it was just too much a pain to mess with.

    I eventually concluded that it was better(less messing around) to VM or dual boot and run Perl of whatever flavor for whatever platform on its intended platform.

    This was my personal experience gathered over a number of years(and jobs) on numerous machines, both personal and work-owned.

    To be fair, MicroSoft lost me as a customer between ~1991 and ~1995 when Linux was really becoming available. I did try for a number of years to get a mix of the two OS's along with Perl running in one environment, but always found myself spending more time messing around than getting work done that way. So eventually I just decided that if I wanted Perl in both arenas, it was easier to set up two arenas than to try to blend them.

    Again, just my experience and perception, but thought I would toss it out there for you...


    ...the majority is always wrong, and always the last to know about it...
    Insanity: Doing the same thing over and over again and expecting different results.
Re: Newb guidance for Perl on MS Windows: Cygwin, Strawberry, ActivePerl?
by Bloodnok (Vicar) on Oct 16, 2013 at 23:28 UTC
    Sorry to be slightly repetitive, but when I've been forced to use Windoze, I've always gone down the Strawberry perl route if, for no other reason, than the fact that it's so much more flexible - good though it may be, I found AS to be lacking in the availability of the right/needed PPM(s) whereas that has never been a problem with Strawberry ... but then again, I try and avoid M$ orientated contracts wheresoever possible.

    In the words of the GB House of Parliament, 'I refer the honourable gentlemen to an earlier answer I gave the house' :-)

    A user level that continues to overstate my experience :-))

      You can use the MinGW compiler with ActivePerl, too. In fact, I believe there's a module installation available, to get it to work.