Jump to content

Perl Compiler?

- - - - -

  • Please log in to reply
10 replies to this topic

#1
RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,254 posts
  • Location:C:\Countries\US
Is there a way to compile Perl scripts using Strawberry Perl?

#2
DarkLordofthePenguins

DarkLordofthePenguins

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 409 posts
There's no such thing as a Perl compiler. Perl is an interpreted language. You can get an interpreter for it here. As for Strawberry Perl, I've never heard of it, so I can't help you with that, but with most interpreters you just go to the CLI and type the name of the interpreter and then the name of the source file and it runs the program.
Programming is a journey, not a destination.

#3
RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,254 posts
  • Location:C:\Countries\US
Programming Perl, 3rd Edition: Chapter 18: Compiling

That page says that the Perl interpreter is a compiler. Or is it talking about a different type of compiler?

How does a perl work, anyway?

#4
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
  • Location:Vancouver, Eh! Cleverness: 200
It can compile but it is not considered what you may think of a compiled language. As I am sure the page you linked to writes, you will notice there is a lexer and parser to scan the Perl script and then generate operation codes (opcodes) which are machine language instructions, which in its compiled form is ran in the interpreter (it interprets the machine language instructions from the operation codes, rather than interpreting the textual script itself)

There lays a C compiler named B::C if I recall to generate a C table based on the operation codes, although that is not really a direct conversion, although it may suffice if you wish for an executable of the Perl script without the interpreter, I believe that is what you can do with it.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#5
RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,254 posts
  • Location:C:\Countries\US
So the Perl interpreter compiles the script and then simulates the processor?

#6
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
  • Location:Vancouver, Eh! Cleverness: 200
That is basically correct, it interprets your textual code in to machine compatible operation codes which can be run by the processor.

You can use a Perl module to actually visualize what those opcodes will be after parsing:
B::Concise - perldoc.perl.org
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#7
RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,254 posts
  • Location:C:\Countries\US
Is that output text assembly language? Or is it just a map of what the opcodes would do?

And the other thing, are the opcodes for Intel processors?

#8
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
  • Location:Vancouver, Eh! Cleverness: 200
In this case they are simply opcodes for the interpreter to work with, so it does not have to deal with any logic or interpretation of the code, it just performs it. You would need to do much more to get assembly out of it, and when you do it will be big (and confusing, as the interpreter needs to do a lot of work and optimizations during conversion)
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#9
RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,254 posts
  • Location:C:\Countries\US
So are those special Perl opcodes, for the the Perl processor emulator?

#10
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
  • Location:Vancouver, Eh! Cleverness: 200
Yes, although it is not really considered emulating, just interpreting directly in to some form of finished machine code that supports the opcode's actions to be ran.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#11
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,722 posts
  • Programming Language:C, Java, C++, PHP, Python, Perl, Assembly, Bash, Others
  • Learning:JavaScript
It's more like Java's bytecode, from my understanding. So no, it can't be run directly on a machine, but it's portable as long as you have a Perl interpreter.
sudo rm -rf /




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users