You are here: Foswiki>PM Web>WebPreferences>Free4All>PerlProjekte>PAR (25 Jul 2005, SteffenSchwigon?)EditAttach

PAR - Das Perlarchiv

Entwickler: Autrijus Tang
aktuelle Version: 0.85
Installation: klassischer Dreisatz oder -MCPAN

(für "ActiveState-Perl-Windowsianer" ohne Compiler)
2004/01/28: Addition It is better to use the ppm program delivered
            with the ActiveState Perl. With Perl 5.8.2 type:

    C:\> ppm3
    # activestate was out of date compared to this one
    % rep add bribes http://www.bribes.org/perl/ppm
    # move it to first place on list of repositories
    % rep up bribes
    CPAN>upgrade -install PAR

And finally, 'q' to quit and that's all :-) You have access to pp and so on...

Dokumentation:

Motivation

  • häufiger Einsatz von Skripten auf wechselnden Rechnern
  • Weitergabe eines kompletten Programms
  • umfangreiche eigene Modulsammlung
  • Module die nicht in der Standarddistribution enthalten sind
  • Skript soll auf verschiedenen Plattformen laufen
  • Zielsystem hat kein Perl (so was ist selten, aber schon beobachtet worden ;-))

Skript hello.pl einpacken in .par

Sicher die häufigste Variante. Der Zielrechner hat ein Perl, aber man ist sich nicht sicher ob alle Module enthalten sind.
joerg@bane~> pp -o hello.par -p hello.pl
Warum pp?
Für diesen Verwendungszweck gut geeignet weil:
  • scannt die Modulabhängigkeiten
  • erzeugt das Archiv
  • packt die Loadermechanik mit ins Archiv
Für GUI-Freaks gibt es alternativ: tkpp

Skript aus dem Archiv starten

joerg@bane~> par.pl hello.par
joerg@bane~> perl -MPAR hello.par hello.pl
auf Systemen ohne Perl oder PAR.pm kann der standalone Loader parl(.exe) zum Einsatz kommen.
joerg@bane~> parl hello.par                 # kein perl or PAR.pm benötigt!

joerg@bane~> parl hello.par hello.pl # ditto

Ein Executable erzeugen

aus dem Archiv:
joerg@bane~> pp -o hello hello.par
aus dem Skript direkt:
joerg@bane~> pp -o hello hello.pl
joerg@bane~> perl -MPAR=hello hello.pl
Nachteile:
  • Executable wird ziemlich groß
  • Probleme mit der libc

Ein Executable ausführen

joerg@bane~>./hello hello.pl
Hint: Heisst das Hauptprogramm main.pl wird es automatisch beim Aufruf des Executables gestartet. Allerdings gab es einige Verwirrungen beim Erzeugen des Archivs.

Nutzung von Archiven aus dem Skript heraus

     use PAR;
use lib "hello.par"; # .par ist optional
use hello;
oder auch so:
     use PAR "/home/joerg/perllibs/*.par";  # schaufelt alle Archive nach @INC
use hello;

Multiarchitektur?

joerg@bane~> pp --multiarch -o test.exe test.par
Dieser Vorgang muss auf jeder gewünschten Zielplattform vorgenommen werden. Zusätzlich dazu muß auf dem Zielsystem später auch PAR installiert sein. Also prinzipiell multiarchitekturfähig, wenn auch mit etwas Aufwand. Auf jeden Fall deutliche besser als Tools ala perl2exe oder Perlapp.

Bekannte Probleme

Module mit Autoload-Mechanismus müssen "händisch" ins Archiv eingetragen werden.

-- JoergWestphal? - 02 Sep 2004

Topic revision: r4 - 25 Jul 2005 - 10:06:48 - SteffenSchwigon?
 
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback