I have a .pl
file and I want to execute that file in any system even though perl
is not installed. How can I achieve it?
What would be some good examples to do that?
Since version 5.005, Perl has shipped with a module capable of inspecting the optimized parse tree ( B ), and this has been used to write many useful utilities, including a module that lets you turn your Perl into C source code that can be compiled into an native executable.
Perl is an interpreted language, which means that your code can be run as-is, without a compilation stage that creates a non-portable executable program. Traditional compilers convert programs into machine language.
pp can create an executable that includes perl and your script (and any module dependencies), but it will be specific to your architecture, so you couldn't run it on both Windows and linux for instance.
From its doc:
To make a stand-alone executable, suitable for running on a machine that doesn't have perl installed:
% pp -o packed.exe source.pl # makes packed.exe # Now, deploy 'packed.exe' to target machine... $ packed.exe # run it
(% and $ there are command prompts on different machines).
Install PAR::Packer
. Example for *nix:
sudo cpan -i PAR::Packer
For Strawberry Perl for Windows or for ActivePerl and MSVC installed:
cpan -i PAR::Packer
Pack it with pp
. It will create an executable named "example" or "example.exe" on Windows.
pp -o example example.pl
This would work only on the OS where it was built.
P.S. It is really hard to find a Unix clone without Perl. Did you mean Windows?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With