What code other than the BEGIN {} and CHECK {} blocks get executed

In Perl 5.10, add UNITCHECK.

Keep in mind that use has an implicit BEGIN.

Other language elements have compile-time effects (e.g. prototypes affect parsing, symbol names vivify entries in the symbol table), but I can't think of any other that will run code.

and under what conditions?

Unconditionally.

What restrictions are there on the kinds of code executed during the syntax check mode?

None.

How does taint mode behave?

Normally.

$ perl -c -Te'BEGIN { system "/bin/ls" }' Insecure $ENV{PATH} while running with -T switch at -e line 1. BEGIN failed--compilation aborted at -e line 1. $ perl -c -Te'BEGIN { $ENV{PATH}=""; system "/bin/ls" }' bin cdrom etc ... -e syntax OK

And if there are none, e.g. anything can be called, is this safe?

No more or less safe than calling it without -c.

What precautions do people use to make sure that code (especially someone else's code) is safe to syntax check?

Safe might help, but that's just a start.

Update: I meant to mention PPI. It might be a suitable alternative.


In reply to Re: What restrictions are there on code execution when running perl in syntax check mode? by ikegami
in thread What restrictions are there on code execution when running perl in syntax check mode? by ELISHEVA

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.