ЭЛЕКТРОННАЯ БИБЛИОТЕКА КОАПП |
Сборники Художественной, Технической, Справочной, Английской, Нормативной, Исторической, и др. литературы. |
20. Perl InternalsContents: It cannot be seen, cannot be felt, - J.R.R. Tolkien, The Hobbit
This chapter is a modest attempt to shed light on most of the critical data structures and functions of the Perl interpreter. Getting a handle on such (admittedly dry) detail will give you the confidence to write powerful extensions, and will inform your judgment about how (and how much) Perl should be used in a given application. The mark of a good Perl programmer is the ability to answer questions that don't figure in the Frequently Asked Questions list, such as these:
And so on. All you require is fluency in C, an enquiring mind, and a comfortable chair. If you are into instant gratification and can't wait to churn out a cool extension, you may opt for the low-fat thread running through this chapter; read the following sections: Section 20.3, "Perl Value Types," Section 20.4, "Stacks and Messaging Protocol," and Section 20.5, "Meaty Extensions." You can definitely skip all sections entitled "Inside..." on a first reading without loss of continuity. 20.1 Reading the SourceThere was this programmer, the story goes, who was deeply mystified by a piece of code. It had no comments at all, and he couldn't for the life of him figure out how it did what it did. For years, he cursed the author of that code, but it continued to fascinate and trouble him. One day, it came to him in a flash. He understood it all. In fact, it was so obvious that he also understood why it didn't need any comments! While the Perl source may be the final repository of all answers, it is a fairly reluctant informant. A lack of comments, generous use of macros, and some breath-taking optimizations make for a rather forbidding task of understanding the code, even for the true die-hard. If you are one of those who just wants to hack it and achieve all kinds of greatness, this chapter should get you adequately primed. In addition, here are some ways of understanding the system better:
This chapter makes frequent references to source files, and while you may find it handy to have them in front of you, it is by no means necessary to do so. |