aninymous has asked for the wisdom of the Perl Monks concerning the following question:

hey all, i am just trying to get familiar with PERL & i would like to know how to get the intermediate code(IR) created by PERL since we need to understand it & translate it to some other suitable representation that we've designed for our project work.It will be nice if someone really replies back with some useful stuff regarding the IR,its urgent, thanx

Replies are listed 'Best First'.
Re: PERL & its IR
by ikegami (Patriarch) on Jan 27, 2005 at 18:08 UTC
    Perl is not compiled down to bytecode like Java. The code is left in tree form. You can use perl -MO=Terse script.pl to see the tree for a piece of code. See B::Concise for options.
      You can use Deparse to see the tree for a piece of code
      I think you meant to say you can use Concise:
      $ perl -MO=Concise -e '$a+$b' 6 <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 1 -e:1) v ->3 5 <2> add[t1] vK/2 ->6 - <1> ex-rv2sv sK/1 ->4 3 <$> gvsv(*a) s ->4 - <1> ex-rv2sv sK/1 ->5 4 <$> gvsv(*b) s ->5 -e syntax OK

      Dave.

      hi, thanx for ur reply, So is "Deparse" a kind of s/w tool to see the parse tree & if so, from where can i get it?
        I posted too fast. I just updated my post to fix the module name, and to add more info.
Re: PERL & its IR
by eyepopslikeamosquito (Archbishop) on Jan 27, 2005 at 21:59 UTC

    If it's urgent and you don't know Perl, it sounds like what you are trying to achieve is very ambitious. There is a steep learning curve to understanding perl internals ... depending on your background and experience, of course. To get started with perl internals, start with perlguts (and its See Also links). If you like books, Extending and Embedding Perl is the best one that I'm aware of.

    If you give us more details on what it is you are trying to achieve, you will probably get more useful advice.

    A reply falls below the community's threshold of quality. You may see it by logging in.