5.4. Exercises

  1. What do you think the LEX_FORMLINE state is for? Work out what it does.

  2. You can put #!perl -p at the top of your file and Perl will behave as though the -p command-line switch was given. Since exactly the same mechanism handles incoming code from a file and from eval, why won't it do that if you say eval qq[#!perl -p]?

  3. Why is --$a++ a syntax error? Explain in terms of how it should be parsed. Look for the PREDEC and POSTINC types in the grammar. What would you need to change to make it parse?

  4. In the current Perl source, just after case "#":, you'll find test marked "Found by Ilya", which tests for a buffer overflow. How could that conceivably occur? Work out what would trigger the error message and produce some Perl code which would do so.