First, perlcc
is a dead tool (although it is in the B::C distro. Virtually no one uses (or used) it. It's not part of the normal Perl development process. It's own docs say:
The code generated in this way is not guaranteed to work. The whole codegen suite (perlcc included) should be considered very experimental. Use for production purposes is strongly discouraged.
Furthermore, it's not typical for people to compile Perl programs to a binary. Plenty of people would like to do that, but that's just not the way it works. What are you trying to accomplish? There might be another way to do what you want to do.
A Perl program really executes in two phases: a compile-time and a run-time.
Perl is more like Java or Ruby than C in this manner. When you run a Perl program, the perl
interpreter loads all the source code and compiles it into a abstract syntax tree. It's that bytecode that perl
executes (or interprets) during the runtime. This is the same sort of thing that Java, Ruby, and Python do.
One of Perl's warts is that it doesn't have a good way to save the result of that compilation, like those other languages can. That means you end up compiling the source every time. There are some ways around that with pperl
and domain-specific tools such as mod_perl or fastcgi.
There are some fuzzy bits in there with BEGIN
blocks, eval
, and so on, but that's mostly the way it works. There are more details in perlmod.
This design wart wouldn't be there if we started all over with everything we know now, and indeed, in Perl 6 it isn't there. :)