Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Perl Compiler?


  • Please log in to reply
10 replies to this topic

#1 RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1311 posts
  • Location:C:\Countries\US
  • Programming Language:C, Java, C++, PHP, Python, JavaScript

Posted 30 March 2011 - 05:08 AM

Is there a way to compile Perl scripts using Strawberry Perl?
  • 0

#2 DarkLordCthulhu

DarkLordCthulhu

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 422 posts
  • Location:The bash shell
  • Programming Language:C, JavaScript, Bash, Others
  • Learning:Ruby, Others

Posted 30 March 2011 - 08:45 AM

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.
  • 0
Programming is a journey, not a destination.

#3 RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1311 posts
  • Location:C:\Countries\US
  • Programming Language:C, Java, C++, PHP, Python, JavaScript

Posted 30 March 2011 - 07:26 PM

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?
  • 0

#4 Alexander

Alexander

    YOL9

  • Moderator
  • 3963 posts
  • Location:Vancouver, Eh! Cleverness: 200
  • Programming Language:C, C++, PHP, Assembly

Posted 30 March 2011 - 08:32 PM

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.
  • 0

All new problems require investigation, and so if errors are problems, try to learn as much as you can and report back.


#5 RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1311 posts
  • Location:C:\Countries\US
  • Programming Language:C, Java, C++, PHP, Python, JavaScript

Posted 30 March 2011 - 08:40 PM

So the Perl interpreter compiles the script and then simulates the processor?
  • 0

#6 Alexander

Alexander

    YOL9

  • Moderator
  • 3963 posts
  • Location:Vancouver, Eh! Cleverness: 200
  • Programming Language:C, C++, PHP, Assembly

Posted 30 March 2011 - 08:53 PM

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
  • 0

All new problems require investigation, and so if errors are problems, try to learn as much as you can and report back.


#7 RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1311 posts
  • Location:C:\Countries\US
  • Programming Language:C, Java, C++, PHP, Python, JavaScript

Posted 30 March 2011 - 09:01 PM

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?
  • 0

#8 Alexander

Alexander

    YOL9

  • Moderator
  • 3963 posts
  • Location:Vancouver, Eh! Cleverness: 200
  • Programming Language:C, C++, PHP, Assembly

Posted 30 March 2011 - 09:05 PM

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)
  • 0

All new problems require investigation, and so if errors are problems, try to learn as much as you can and report back.


#9 RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1311 posts
  • Location:C:\Countries\US
  • Programming Language:C, Java, C++, PHP, Python, JavaScript

Posted 30 March 2011 - 09:07 PM

So are those special Perl opcodes, for the the Perl processor emulator?
  • 0

#10 Alexander

Alexander

    YOL9

  • Moderator
  • 3963 posts
  • Location:Vancouver, Eh! Cleverness: 200
  • Programming Language:C, C++, PHP, Assembly

Posted 30 March 2011 - 09:39 PM

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.
  • 0

All new problems require investigation, and so if errors are problems, try to learn as much as you can and report back.


#11 dargueta

dargueta

    I chown trolls.

  • Moderator
  • 4854 posts
  • Programming Language:C, Java, C++, PHP, Python, JavaScript, Perl, Assembly, Bash, Others
  • Learning:Objective-C

Posted 04 April 2011 - 01:50 PM

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.
  • 0

sudo rm -rf / && echo $'Sanitize your inputs!'





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download