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

Perl to go.

I dont work in the computer field... Actually, I work in the medical field. However, in my downtime at work I sometimes like to play around with ideas in perl. I have computer access, but no access to install software.

In the past, I have run ssh client from a usb thumbdrive to my computer at home. However, I really didnt like the idea of my password possibly being logged since there is monitoring software.

Well, how about a full perl distribution on a thumbdrive? Talk about portable. I could take my perl, modules, editor and code with me.

Here is what I wanted.

I wanted to be able to insert my thumbdrive click on a shortcut and have cmd prompt pop-up with perl, my editor, and unix utils in my path. Here is what I did to get it working.

The systems I wanted to use this on would be running either windows XP or Windows 2000. Instead of messing with trying to get Activestate to work I compiled perl from the source.

The stuff

First I installed mingw which was used to compile perl. The procedure was quite simple, install the software and add to your path. Next download dmake and add it to your path.

If you dont want to install perl to c:\perl then you need to edit the file makefile.mk. The config file is allready setup to use with mingw right out of the box. Then fire up a cmd shell, and do the following:

c:\src\perl-5.8.7> cd win32 c:\src\perl-5.8.7> dmake c:\src\perl-5.8.7> dmake test c:\src\perl-5.8.7> dmake install

NOTE:
If you install the unix utilities and add to your path beware of the following problem. The unix utilities adds a program called type.exe that will cause errors on the following tests:

  • ../ext/IO/t/io_dup.t
  • comp/multiline.t
  • io/dup.t
This is due to how the tests try to call 'type' using the backticks and invoking the installed type.exe instead of the shell's version. Remove the type.exe from path and you are fine.

Then you just copy over the c:\perl over to your thumbdrive. Perl to go. To save some space you can also delete the html docs.

I also then added the unix utils to the thumbdrive and also the vim editor.

The next problem was how to deal with the drive allways being on a different volume from computer to computer.. One computer it would be drive I: the other e: for example... And how can I set the path to my binaries??

My solution is one batch file and a small perl script.

Batch file: start-cmd.bat

programs\perl\bin\perl.exe src\perl\autostart.pl

Perl file: autostart.pl

use strict; use warnings; use File::Spec; my $cur_dir = File::Spec->curdir(); $cur_dir = File::Spec->rel2abs unless ( File::Spec->file_name_is_absolute($cur_dir) ); my $drive = (File::Spec->splitpath($cur_dir))[0]; $drive .= '\\'; my @paths = ( 'programs\\perl\\bin', 'programs\\bin', 'programs\\dmake', 'programs\\usr\local\wbin' ); my $path = '%PATH%;'; foreach my $item (@paths) { my $tmp = File::Spec->catpath($drive,$item); $path .= File::Spec->canonpath($tmp) . ';'; } my $path_cmd = "set path=$path"; print "Current directory: $cur_dir\n"; print "Current drive: $drive\n"; print "Path to be set: $path_cmd\n"; exec ("cmd.exe /K $path_cmd") or die "Couldn't exec cmd.exe: $!\n";

Tada!!! Now I just double-click on the batch file start-cmd.bat and I have a cmd window with the path set to all of my binaries. No matter what drive it is mapped to I have a nice portable perl development environment to go. :)

zzSPECTREz