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.


In reply to Never without (win32) perl by lepetitalbert

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.