Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

comment on

( [id://3333]=superdoc: 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.


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":



  • 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 scrutinizing the Monastery: (4)
As of 2024-04-16 16:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found