Live Chat!

convert perl scripts into binaries

          0 votos

September 26th, 2006 mysurface Posted in Developer, Misc, file, perl, perlcc | Hits: 6175 |

You can covert perl script into ELF binary files, c source code, bytecode etc. You do this my using perlcc.

You can have list of examples by just

man perlcc

But here, i gonna only show you few. First let us generate a perl script, create a file call hello

#!/usr/bin/perl
print "hello world. ";

Convert it into executable,

chmod +x hello

Try to run it, that is our normal perl script.

To make it as a binary with ELF header, do this

perlcc -o hello-bin hello

So what is the different? Check with file command,

file hello*

Output:

hello:     perl script text executable
hello-bin: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not stripped

File shows that “hello” is perl script, where “hello-bin” is a ELF executable binary file.
Usually if you want to do a single line perl, you do this

perl -e 'print "hello world. " '

Now same thing, if you want to convert a single line perl to bin, you do this

perlcc -e 'print "hello world. " ' -o hello-bin

Leave a Reply