in reply to Why is perl -MO=Deparse -f obf.txt unsafe?

> It is my understanding, that perl -MO=Deparse does not actually run the PERL code. Is that correct?

No it isn't, Deparse needs to compile and BEGIN blocks are executed then.

Just try perl -c with code printing in a BEGIN block.

perlrun has more details.

> -c

> causes Perl to check the syntax of the program and then exit without executing it. Actually, it will execute andBEGIN , UNITCHECK , or CHECK blocks and any use statements: these are considered as occurring outside the execution of your program. INIT and END blocks, however, will be skipped.

Also perlmod#BEGIN%2c-UNITCHECK%2c-CHECK%2c-INIT-and-END

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

Replies are listed 'Best First'.
Re^2: Why is perl -MO=Deparse -f obf.txt unsafe?
by vpelss (Initiate) on Feb 06, 2016 at 19:13 UTC

    Ah, BEGIN....

    So is that an oversight in the B::Deparse backend module or is there a useful reason perl -c runs the BEGIN code?

    Sure you show the warning in perlrun, but shouldn't there be a warning label or something on B::Deparse?
      Every use happens at begin time including the execution of import

      You can't compile without executing use and obviously you can't decompile without compiling.

      Welcome in the world of dynamic languages. :)

      Cheers Rolf
      (addicted to the Perl Programming Language and ☆☆☆☆ :)
      Je suis Charlie!

      update

      Maybe you should clarify your intentions, this smells like an XY Problem

      Its the parser that runs BEGIN blocks, not the deparser.