11

At work I'm using Perl 5.8.0 on Windows.

When I first put Perl on, I went to CPAN, downloaded all the sources, made a few changes (in the .MAK file(?) to support threads, or things like that), and did nmake / nmake test / nmake install. Then, bit by bit, I've downloaded individual modules from CPAN and done the nmake dance.

So, I'd like to upgrade to a more recent version, but the new one must not break any existing scripts. Notably, a bunch of "use" modules that I've installed must be installed in the new version.

What's the most reliable (and easiest) way to update my current version, ensuring that everything I've done with the nmake dance will still be there after updating?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
piCookie
  • 9,640
  • 2
  • 19
  • 19
  • It may be a good idea if someone changes the title of this to 'How to update perl on windows', or something similar. – Leon Timmermans Sep 22 '08 at 22:03
  • I suggest "How to update Perl on Windows without losing modules." I started to give my answer, then realized it didn't fit because my answer is UNIX-only, and requires you to reinstall all of your modules (which I think is going to be a requirement anyway). – skiphoppy Sep 24 '08 at 19:10
  • Thanks for the title suggestions. I've edited to reflect your suggestions. – piCookie Oct 07 '08 at 14:59

7 Answers7

9

As others noted, start by installing the new perl in a separate place. I have several perls installed, each completely separate from all of the others.

To do that, you'll have to configure and compile the sources yourself. When you run configure, you'll get a chance to specify the installer. I gave detailed instructions for this in an "Compiling My Own Perl" in the Spring 2008 issue of The Perl Review. There's also an Item in Effective Perl Programming that shows you how to do it.

Now, go back to your original distribution and run cpan -a to create an autobundle file. This is a Pod document that lists all of the extra stuff you've installed, and CPAN.pm understands how to use that to reinstall everything.

To install things in the new perl, use that perl's path to start CPAN.pm and install the autobundle file you created. CPAN.pm will get the right installation paths from that perl's configuration.

Watch the output to make sure things go well. This process won't install the same versions of the modules, but the latest versions.

As for Strawberry Perl, there's a "portable" version you can install somewhere besides the default location. That way you could have the new perl on removable media. You can test it anywhere you like without disturbing the local installation. I don't think that's quite ready for general use though. The Berrybrew tool might help you manage that.

Good luck, :)

brian d foy
  • 129,424
  • 31
  • 207
  • 592
8

I would seriously consider looking at using Strawberry Perl.

brian d foy
  • 129,424
  • 31
  • 207
  • 592
Andy Lester
  • 91,102
  • 13
  • 100
  • 152
  • 1
    Strawberry perl doesn't appear to give me any option about where it's installing. That's a deal breaker in my case. – piCookie Sep 22 '08 at 21:44
4

You can install a second version of Perl in a different location. You'll have to re-install any non-core modules into the new version. In general, different versions of Perl are not binary compatible, which could be an issue if you have any program-specific libraries that utilize XS components. Pure Perl modules shouldn't be affected.

Michael Carman
  • 30,628
  • 10
  • 74
  • 122
3

If you stay within the 5.8 track, all installed modules that contain XS (binary) extensions will continue to work, as binary compatibility is guaranteed within the same 5.8 series. If you moved to 5.10 then you would have to recompile any modules that contain XS components.

All you need to do is ensure that the new build lists the previous include directories in its @INC array (which is used to look for modules).

By the sounds of it, I think you're on Windows, in which case the current @INC paths can be viewed with

perl -le "print for @INC"

Make sure you target your new Perl version in another directory. It will happily coexist with the previous version, and this will allow you to choose which Perl installation gets used; it's just a question of getting your PATH order sorted out. As soon as a Perl interpreter is started up, it knows where to look for the rest of its modules.

Strawberry Perl is probably the nicest distribution on Windows these days for rolling your own.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
dland
  • 4,319
  • 6
  • 36
  • 60
  • Does Strawberry allow me to add modules that I've rolled into the 5.8 chain? I'm most happy to move to the latest version, so maintaining 5.8 isn't interesting. – piCookie Sep 22 '08 at 21:32
1

When I did it I installed the newer one into a separate directory. There's a bit of added confusion running two versions, but it definitely helps make sure everything's working first, and provides a quick way of switching back to the old one in a pinch. I also set up Apache to run two separate services, so I could monkey around with the newer Perl in one service without touching the production one on the old Perl.

It's probably a lot wiser, in hindsight, to install on a separate computer, and do your testing there. Record every configuration change you need to make.

I am not sure about building it yourself—I always just used prepackaged binaries for Windows.

I'm not sure I understand exactly what you're asking. Do you have a list of changes you made to the 5.8 makefile? Or is the question how to obtain such a list? Are you also asking how to find out which packages above the base install you've obtained from CPAN? Are you also asking how to test that your custom changes won't break those packages if you get them from CPAN again?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Kev
  • 15,899
  • 15
  • 79
  • 112
  • Given the large number of modifications, the prepackages probably won't work. I've also installed into version named folders and linked from a generic R:\PERL folder to help switching. – piCookie Sep 22 '08 at 20:48
  • The changes to the 5.8 makefile are unimportant. I'm more asking how to find which packages above the base install I've obtained. I have a lot of scripts that say "use xxx" where xxx was downloaded and built in. They all need to continue working. – piCookie Sep 23 '08 at 15:12
  • This may be a bit lame, but you could use TextPad's "Find in Files" or equivalent to search all your scripts for "^use ". – Kev Oct 07 '08 at 15:09
1

I think the answer to this involves virtualisation of some kind:

  1. Set up an exact copy of your current live machine. Upgrade Perl, using the same directory locations and structures as you're using at the moment.
  2. Go through your scripts testing them on the new image.
  3. Once you're happy, flip the switch.

The thinking behind this is that there's probably all sorts of subtle dependencies and assumptions you haven't thought of. While unlikely, the latest version of a particular module (possibly even a core module, although that's even more unlikely) might have a subtle difference compared to the one you were using. Unless you've exhaustively gone through your entire codebase, there's quite possibly a particular module that's required only under certain circumstances.

You can try and spot this by building a list of all your scripts - a list that you should have anyway, by dint of all your code being under version control (you are using version control, e.g. Subversion, yes?) - and iterating through it, running perl -c on each script. e.g. this script. That sort of automated test is invaluable: you can set it running, go away for a coffee or whatever, and come back to check whether everything worked. The first few times you'll probably find an obscure module that you'd forgotten about, which is fine: the whole point of automating this is so that you don't have to do the drudge-work of checking every single script.

brian d foy
  • 129,424
  • 31
  • 207
  • 592
Sam Kington
  • 1,202
  • 11
  • 14
0

Why don't you use ActivePerl and its "ppm" tool to (re)install modules?

alt text

Alexander Farber
  • 21,519
  • 75
  • 241
  • 416
  • The reason is that I already had a perl installation with additional modules installed via compiling and installing, and I wanted something that would upgrade that perl installation without losing anything that I had already added. If there is no automated way, I may have to switch to an entirely new perl release as you suggest. – piCookie Jan 26 '11 at 04:48
  • you can get a list of installed modules using "ppm list site". "ppm area list" to get a list of areas. "ppm area sync site" to update the ppm database with packages that have been installed not using ppm. – lexicalscope Dec 12 '11 at 17:06