Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Never without (win32) perl

by lepetitalbert (Monsignor)
on Nov 04, 2005 at 00:27 UTC ( #505563=CUFP: print w/ replies, xml ) Need Help??

Hello dear Monks,

Since I use perl I tried to make my scripts standalone to have them always with me on my USB stick.

I tried the PAR Module, perl2exe, tinyperl but was never really happy with any of them.

and here's how I did it finally :

download and install AS perl.

copy the following code to /perl/bin.

use strict; use warnings; use File::Copy; my $basedir = "../../miniperl/"; my @DIRS = ( "bin" , "lib" , "lib/Exporter" , "lib/Tie" , "lib/warnings" ); my @FILES = ( "lib/Autoloader.pm" , "lib/Carp.pm" , "lib/Config.pm" , "lib/Dynaloader.pm" , "lib/Exporter.pm" , "lib/Socket.pm" , "lib/strict.pm" , "lib/vars.pm" , "lib/warnings.pm" , "lib/XSLoader.pm" , "lib/Exporter/Heavy.pm" , "lib/Tie/Hash.pm" , "lib/warnings/register.pm" ); print "\n creating directory tree ..."; mkdir( "$basedir") || die " Cannot mkdir $basedir \n $!"; foreach (@DIRS) { mkdir( $basedir . $_ ) || die " Cannot mkdir $basedir$_ \n $!"; } print "\n\n copying files ..."; copy("perl.exe", $basedir . "bin/perl.exe") or die "\n cannot copy perl.exe\n"; copy("perl58.dll", $basedir . "bin/perl58.dll") or die "\n cannot copy perl58.dll \n"; foreach (@FILES) { copy( "../" . $_ , $basedir . $_ ) or die "\n shit : shit : ../$_ $basedir$_\n"; } print "\n\n done. \n";

and run it.

this will create a dir miniperl (beside the perl dir), with a minimal(972ko) perl dist. (tested with the camel code only)

You can then add the files required to run you script

The code above require File::Copy

The following code creates the minimal dist to create a mini-perl (1.2Mo):

use strict; use warnings; use File::Copy; my $basedir = "../../miniperl/"; my @DIRS = ( "bin" , "lib" , "lib/Exporter" , "lib/File" , "lib/Thread +" , "lib/Tie" , "lib/warnings" , "lib/File/Spec" ); my @FILES = ( "lib/Autoloader.pm" , "lib/Carp.pm" , "lib/Config.pm" , "lib/Dynaloader.pm" , "lib/Exporter.pm" , "lib/Socket.pm" , "lib/strict.pm" , "lib/vars.pm" , "lib/warnings.pm" , "lib/XSLoader.pm" , "lib/Exporter/Heavy.pm" , "lib/Tie/Hash.pm" , "lib/warnings/register.pm" , "lib/File/Basename.pm" , "lib/File/CheckTree.pm" , "lib/File/Compare.pm" , "lib/File/Copy.pm" , "lib/File/DosGlob.pm" , "lib/File/Find.pm" , "lib/File/Glob.pm" , "lib/File/Path.pm" , "lib/File/Spec.pm" , "lib/File/stat.pm" , "lib/File/Temp.pm" , "lib/File/Spec/Cygwin.pm" , "lib/File/Spec/Epoc.pm" , "lib/File/Spec/Functions.pm" , + "lib/File/Spec/Mac.pm" , "lib/File/Spec/OS2.pm" , "lib/File/Spec/Unix.pm" , "lib/File/Spec/VMS.pm" , "lib/File/Spec/Win32.pm" , "lib/Thread/Queue.pm" , "lib/Thread/Semaphore.pm" , "lib/Thread/Signal.pm" , "lib/Thread/Specific.pm" , ); print "\n creating directory tree ..."; mkdir( "$basedir") || die " Cannot mkdir $basedir \n $!"; foreach (@DIRS) { mkdir( $basedir . $_ ) || die " Cannot mkdir $basedir$_ \n $!"; } print "\n\n copying files ..."; copy("perl.exe", $basedir . "bin/perl.exe") or die "\n cannot copy perl.exe\n"; copy("perl58.dll", $basedir . "bin/perl58.dll") or die "\n cannot copy perl58.dll \n"; foreach (@FILES) { copy( "../" . $_ , $basedir . $_ ) or die "\n shit : shit : ../$_ $basedir$_\n"; } print "\n\n done. \n";

The last one works with a script wich uses this :

use warnings; use strict; use Socket; use Win32::OLE qw(in); use Win32::TieRegistry; use Time::HiRes qw( time gettimeofday tv_interval );

# -------------------------------------------------------------------- +--------- use strict; use warnings; use File::Copy; my $basedir = "../../miniperl/"; my @DIRS = ( "bin" , "lib" , "lib/auto" , "lib/Exporter" , "lib/Tie" , "lib/Time" , "lib/warnings" , "site" , "lib/auto/Socket" , "lib/auto/Time" , "lib/auto/Win32" , "lib/auto/Time/HiRes" , "site/lib" , "site/lib/auto" , "site/lib/Win32" , "site/lib/Win32API" , "site/lib/auto/Win32" , "site/lib/auto/Win32API" , "site/lib/auto/Win32API/Registry" , "site/lib/auto/Win32/ +OLE" , "site/lib/auto/Win32/Registry" , "site/lib/auto/Win32/Ser +vice" , "site/lib/Win32/OLE" , "site/lib/auto/Win32/WinError" , "site/lib/Win32API/Registry"); my @FILES = ( "lib/Autoloader.pm" , "lib/Carp.pm" , "lib/Config.pm" , "lib/Dynaloader.pm" , "lib/Exporter.pm" , "lib/Socket.pm +" , "lib/strict.pm" , "lib/vars.pm" , "lib/warnings.pm" , "lib/XSLoader.pm" , "lib/auto/Socket/Socket.dll" , "lib/auto/Time/HiRes/HiRes.dll" , "lib/auto/Win32/Win32. +dll" , "lib/Exporter/Heavy.pm" , "lib/Tie/Hash.pm" , "lib/Time/ +HiRes.pm" , "lib/warnings/register.pm" , "site/lib/Win32/OLE.pm" , "site/lib/Win32/Registry.pm" , "site/lib/Win32/TieRegist +ry.pm" , "site/lib/Win32/WinError.pm" , "site/lib/auto/Win32/OLE/ +OLE.dll" , "site/lib/auto/Win32/Registry/Registry.dll" , "site/lib/auto/Win32/Service/Service.dll" , "site/lib/auto/Win32API/Registry/Registry.dll" , "site/lib/Win32/OLE/Lite.pm" , "site/lib/auto/Win32/WinError/WinError.dll" , "site/lib/Win32API/Registry/cRegistry.pc" , "site/lib/Win32API/Registry.pm" ); print "\n creating directory tree ..."; mkdir( "$basedir") || die " Cannot mkdir $basedir \n $!"; foreach (@DIRS) { mkdir( $basedir . $_ ) || die " Cannot mkdir $_ \n $!"; } print "\n\n copying files ..."; copy("perl.exe", $basedir . "bin/perl.exe") or die "\n cannot copy perl.exe to " . $basedir . "bin/perl.exe\n"; copy("perl58.dll", $basedir . "bin/perl58.dll") or die "\n cannot copy perl58.dll to " . $basedir . "bin/perl58.dll\n +"; foreach (@FILES) { copy( "../" . $_ , $basedir . $_ ) or die "\n cannot copy ../$_ to $basedir$_\n"; } print "\n\n done. \n";

This one is 1.70Mo

That's it.

Have a nice day.

Comment on Never without (win32) perl
Select or Download Code
Re: Never without (win32) perl
by planetscape (Canon) on Nov 04, 2005 at 05:31 UTC
Re: Never without (win32) perl
by parv (Priest) on Nov 05, 2005 at 08:07 UTC

    Can you share what you did not like about PAR? I was thinking of using PAR to create a Perl distribution for myself (but since i have not used Windows in a while, i did not do much).

      Hello,

      first I'm a PAR noob so what follows may be wrong.

      I only used pp to create .exe files (it seems there are a lot of other uses for PAR).

      The .exe is a self-executable archive, and it extracts to the Tmp directory, and is executed from there.

      Depending on how (or where) you use the .exe, this may not be a problem.

      My scripts often run on clients machine on which I have to leave no trace, and don't know if I'll have enough rights on the Tmp directory to run something.

      So best is to try cos it works nice.

      Have a nice day

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: CUFP [id://505563]
Approved by BrowserUk
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2014-08-23 11:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (173 votes), past polls