Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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

In reply to Portable perl: usb thumbdrive by zzspectrez

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-24 23:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found