史萊姆論壇

返回   史萊姆論壇 > 教學文件資料庫 > 作業系統操作技術文件
忘記密碼?
註冊帳號 論壇說明 標記討論區已讀

歡迎您來到『史萊姆論壇』 ^___^

您目前正以訪客的身份瀏覽本論壇,訪客所擁有的權限將受到限制,您可以瀏覽本論壇大部份的版區與文章,但您將無法參與任何討論或是使用私人訊息與其他會員交流。若您希望擁有完整的使用權限,請註冊成為我們的一份子,註冊的程序十分簡單、快速,而且最重要的是--註冊是完全免費的!

請點擊這裡:『註冊成為我們的一份子!』

Google 提供的廣告


 
 
主題工具 顯示模式
舊 2004-05-20, 11:40 AM   #1
mic64
註冊會員
 
mic64 的頭像
榮譽勳章
UID - 582
在線等級: 級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時
註冊日期: 2002-12-06
VIP期限: 2007-04
住址: MIB總部
文章: 412
精華: 0
現金: 499 金幣
資產: 499 金幣
預設 Perl in a Nutshell

Perl in a Nutshell
Perl is a language for getting your job done.

Of course, if your job is programming, you can get your job done with any "complete" computer language, theoretically speaking. But we know from experience that computer languages differ not so much in what they make possible, but in what they make easy. At one extreme, the so-called "fourth generation languages" make it easy to do some things, but nearly impossible to do other things. At the other extreme, certain well known, "industrial-strength" languages make it equally difficult to do almost everything.

Perl is different. In a nutshell, Perl is designed to make the easy jobs easy, without making the hard jobs impossible.

And what are these "easy jobs" that ought to be easy? The ones you do every day, of course. You want a language that makes it easy to manipulate numbers and text, files and directories, computers and networks, and especially programs. It should be easy to run external programs and scan their output for interesting tidbits. It should be easy to send those same tidbits off to other programs that can do special things with them. It should be easy to develop, modify, and debug your own programs too. And, of course, it should be easy to compile and run your programs, and do it portably, on any modern operating system.

Perl does all that, and a whole lot more.

Initially designed as a glue language for the UNIX operating system (or any of its myriad variants), Perl also runs on numerous other systems, including MS-DOS, VMS, OS/2, Plan 9, Macintosh, and any variety of Windows you care to mention. It is one of the most portable programming languages available today. To program C portably, you have to put in all those strange #ifdef markings for different operating systems. And to program a shell portably, you have to remember the syntax for each operating system's version of each command, and somehow find the least common denominator that (you hope) works everywhere. Perl happily avoids both of these problems, while retaining many of the benefits of both C and shell programming, with some additional magic of its own. Much of the explosive growth of Perl has been fueled by the hankerings of former UNIX programmers who wanted to take along with them as much of the "old country" as they could. For them, Perl is the portable distillation of UNIX culture, an oasis in the wilderness of "can't get there from here". On the other hand, it works in the other direction, too: Web programmers are often delighted to discover that they can take their scripts from a Windows machine and run them unchanged on their UNIX servers.

Although Perl is especially popular with systems programmers and Web developers, it also appeals to a much broader audience. The hitherto well-kept secret is now out: Perl is no longer just for text processing. It has grown into a sophisticated, general-purpose programming language with a rich software development environment complete with debuggers, profilers, cross-referencers, compilers, interpreters, libraries, syntax-directed editors, and all the rest of the trappings of a "real" programming language. (But don't let that scare you: nothing requires you to go tinkering under the hood.) Perl is being used daily in every imaginable field, from aerospace engineering to molecular biology, from computer-assisted design/computer-assisted manufacturing (CAD/CAM) to document processing, from database manipulation to client-server network management. Perl is used by people who are desperate to analyze or convert lots of data quickly, whether you're talking DNA sequences, Web pages, or pork belly futures. Indeed, one of the jokes in the Perl community is that the next big stock market crash will probably be triggered by a bug in a Perl script. (On the brighter side, any unemployed stock analysts will still have a marketable skill, so to speak.)

There are many reasons for the success of Perl. It certainly helps that Perl is freely available, and freely redistributable. But that's not enough to explain the Perl phenomenon, since many freeware packages fail to thrive. Perl is not just free; it's also fun. People feel like they can be creative in Perl, because they have freedom of expression: they get to choose what to optimize for, whether that's computer speed or programmer speed, verbosity or conciseness, readability or maintainability or reusability or portability or learnability or teachability. You can even optimize for obscurity, if you're entering an Obfuscated Perl contest.

Perl can give you all these degrees of freedom because it's essentially a language with a split personality. It's both a very simple language and a very rich language. It has taken good ideas from nearly everywhere, and installed them into an easy-to-use mental framework. To those who merely like it, Perl is the Practical Extraction and Report Language. To those who love it, Perl is the Pathologically Eclectic Rubbish Lister. And to the minimalists in the crowd, Perl seems like a pointless exercise in redundancy. But that's okay. The world needs a few reductionists (mainly as physicists). Reductionists like to take things apart. The rest of us are just trying to get it together.

Perl is in many ways a simple language. You don't have to know many special incantations to compile a Perl program--you can just execute it like a shell script. The types and structures used by Perl are easy to use and understand. Perl doesn't impose arbitrary limitations on your data--your strings and arrays can grow as large as they like (so long as you have memory), and they're designed to scale well as they grow. Instead of forcing you to learn new syntax and semantics, Perl borrows heavily from other languages you may already be familiar with (such as C, and sed, and awk, and English, and Greek). In fact, just about any programmer can read a well-written piece of Perl code and have some idea of what it does.

Most important, you don't have to know everything there is to know about Perl before you can write useful programs. You can learn Perl "small end first". You can program in Perl Baby-Talk, and we promise not to laugh. Or more precisely, we promise not to laugh any more than we'd giggle at a child's creative way of putting things. Many of the ideas in Perl are borrowed from natural language, and one of the best ideas is that it's okay to use a subset of the language as long as you get your point across. Any level of language proficiency is acceptable in Perl culture. We won't send the language police after you. A Perl script is "correct" if it gets the job done before your boss fires you.

Though simple in many ways, Perl is also a rich language, and there is much to be learned about it. That's the price of making hard things possible. Although it will take some time for you to absorb all that Perl can do, you will be glad that you have access to the extensive capabilities of Perl when the time comes that you need them. We noted above that Perl borrows many capabilities from the shells and C, but Perl also possesses a strict superset of sed and awk capabilities. There are, in fact, translators supplied with Perl to turn your old sed and awk scripts into Perl scripts, so you can see how the features you may already be familiar with correspond to those of Perl.

Because of that heritage, Perl was a rich language even when it was "just" a data-reduction language, designed for navigating files, scanning large amounts of text, creating and obtaining dynamic data, and printing easily formatted reports based on that data. But somewhere along the line, Perl started to blossom. It also became a language for filesystem manipulation, process management, database administration, client-server programming, secure programming, Web-based information management, and even for object-oriented and functional programming. These capabilities were not just slapped onto the side of Perl--each new capability works synergistically with the others, because Perl was designed to be a glue language from the start.

But Perl can glue together more than its own features. Perl is designed to be modularly extensible. Perl allows you to rapidly design, program, debug, and deploy applications, but it also allows you to easily extend the functionality of these applications as the need arises. You can embed Perl in other languages, and you can embed other languages in Perl. Through the module importation mechanism, you can use these external definitions as if they were built-in features of Perl. Object-oriented external libraries retain their object-orientedness in Perl.

Perl helps you in other ways too. Unlike a strictly interpreted language such as the shell, which compiles and executes a script one command at a time, Perl first compiles your whole program quickly into an intermediate format. Like any other compiler, it performs various optimizations, and gives you instant feedback on everything from syntax and semantic errors to library binding mishaps. Once Perl's compiler frontend is happy with your program, it passes off the intermediate code to the interpreter to execute (or optionally to any of several modular back ends that can emit C or bytecode.) This all sounds complicated, but the compiler and interpreter are quite efficient, and most of us find that the typical compile-run-fix cycle is measured in mere seconds. Together with Perl's many fail-soft characteristics, this quick turnaround capability makes Perl a language in which you really can do rapid prototyping. Then later, as your program matures, you can tighten the screws on yourself, and make yourself program with less flair but more discipline. Perl helps you with that too, if you ask nicely.

Perl also helps you to write programs more securely. While running in privileged mode, you can temporarily switch your identity to something innocuous before accessing system resources. Perl also guards against accidental security errors through a data tracing mechanism that automatically determines which data was derived from insecure sources and prevents dangerous operations before they can happen. Finally, Perl lets you set up specially protected compartments in which you can safely execute Perl code of dubious lineage, masking out dangerous operations. System administrators and CGI programmers will particularly welcome these features.

But, paradoxically, the way in which Perl helps you the most has almost nothing to do with Perl, and everything to do with the people who use Perl. Perl folks are, frankly, some of the most helpful folks on earth. If there's a religious quality to the Perl movement, then this is at the heart of it. Larry wanted the Perl community to function like a little bit of heaven, and he seems to have gotten his wish, so far. Please do your part to keep it that way.

Whether you are learning Perl because you want to save the world, or just because you are curious, or because your boss told you to, this handbook will lead you through both the basics and the intricacies. And although we don't intend to teach you how to program, the perceptive reader will pick up some of the art, and a little of the science, of programming. We will encourage you to develop the three great virtues of a programmer: laziness, impatience, and hubris. Along the way, we hope you find the book mildly amusing in some spots (and wildly amusing in others). And if none of this is enough to keep you awake, just keep reminding yourself that learning Perl will increase the value of your resume. So keep reading.
mic64 目前離線  
送花文章: 0, 收花文章: 21 篇, 收花: 61 次
舊 2004-05-20, 11:43 AM   #2 (permalink)
註冊會員
 
mic64 的頭像
榮譽勳章
UID - 582
在線等級: 級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時
註冊日期: 2002-12-06
VIP期限: 2007-04
住址: MIB總部
文章: 412
精華: 0
現金: 499 金幣
資產: 499 金幣
預設

1. An Overview of Perl
Contents:
Getting Started
Natural and Artificial Languages
A Grade Example
Filehandles
Operators
Control Structures
Regular Expressions
List Processing
What You Don't Know Won't Hurt You (Much)



1.1 Getting Started
We think that Perl is an easy language to learn and use, and we hope to convince you that we're right. One thing that's easy about Perl is that you don't have to say much before you say what you want to say. In many programming languages, you have to declare the types, variables, and subroutines you are going to use before you can write the first statement of executable code. And for complex problems demanding complex data structures, this is a good idea. But for many simple, everyday problems, you would like a programming language in which you can simply say:



print "Howdy, world!\n";

and expect the program to do just that.

Perl is such a language. In fact, the example is a complete program,[1] and if you feed it to the Perl interpreter, it will print "Howdy, world!" on your screen.

[1] Or script, or application, or executable, or doohickey. Whatever.

And that's that. You don't have to say much after you say what you want to say, either. Unlike many languages, Perl thinks that falling off the end of your program is just a normal way to exit the program. You certainly may call the exit function explicitly if you wish, just as you may declare some of your variables and subroutines, or even force yourself to declare all your variables and subroutines. But it's your choice. With Perl you're free to do The Right Thing, however you care to define it.

There are many other reasons why Perl is easy to use, but it would be pointless to list them all here, because that's what the rest of the book is for. The devil may be in the details, as they say, but Perl tries to help you out down there in the hot place too. At every level, Perl is about helping you get from here to there with minimum fuss and maximum enjoyment. That's why so many Perl programmers go around with a silly grin on their face.

This chapter is an overview of Perl, so we're not trying to present Perl to the rational side of your brain. Nor are we trying to be complete, or logical. That's what the next chapter is for.[2] This chapter presents Perl to the other side of your brain, whether you prefer to call it associative, artistic, passionate, or merely spongy. To that end, we'll be presenting various views of Perl that will hopefully give you as clear a picture of Perl as the blind men had of the elephant. Well, okay, maybe we can do better than that. We're dealing with a camel here. Hopefully, at least one of these views of Perl will help get you over the hump.

[2] Vulcans (and like-minded humans) should skip this overview and go straight to Chapter 2, The Gory Details, for maximum information density. If, on the other hand, you're looking for a carefully paced tutorial, you should probably get Randal's nice book, Learning Perl (published by O'Reilly & Associates). But don't throw out this book just yet.
mic64 目前離線  
送花文章: 0, 收花文章: 21 篇, 收花: 61 次
舊 2004-05-20, 11:44 AM   #3 (permalink)
註冊會員
 
mic64 的頭像
榮譽勳章
UID - 582
在線等級: 級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時
註冊日期: 2002-12-06
VIP期限: 2007-04
住址: MIB總部
文章: 412
精華: 0
現金: 499 金幣
資產: 499 金幣
預設

2. The Gory Details
Contents:
Lexical Texture
Built-in Data Types
Terms
Pattern Matching
Operators
Statements and Declarations
Subroutines
Formats
Special Variables



This chapter describes in detail the syntax and semantics of a Perl program. Individual Perl functions are described in Chapter 3, Functions, and certain specialized topics such as References and Objects are deferred to later chapters.

For the most part, this chapter is organized from small to large. That is, we take a bottom-up approach. The disadvantage is that you don't necessarily get the Big Picture before getting lost in a welter of details. But the advantage is that you can understand the examples as we go along. (If you're a top-down person, just turn the book over and read the chapter backward.)

2.1 Lexical Texture
Perl is, for the most part, a free-form language. The main exceptions to this are format declarations and quoted strings, because these are in some senses literals. Comments are indicated by the # character and extend to the end of the line.

Perl is defined in terms of the ASCII character set. However, string literals may contain characters outside of the ASCII character set, and the delimiters you choose for various quoting mechanisms may be any non-alphanumeric, non-whitespace character.

Whitespace is required only between tokens that would otherwise be confused as a single token. All whitespace is equivalent for this purpose. A comment counts as whitespace. Newlines are distinguished from spaces only within quoted strings, and in formats and certain line-oriented forms of quoting.

One other lexical oddity is that if a line begins with = in a place where a statement would be legal, Perl ignores everything from that line down to the next line that says =cut. The ignored text is assumed to be POD, or plain old documentation. (The Perl distribution has programs that will turn POD commentary into manpages, LaTeX, or HTML documents.)
mic64 目前離線  
送花文章: 0, 收花文章: 21 篇, 收花: 61 次
舊 2004-05-20, 01:06 PM   #4 (permalink)
註冊會員
 
mic64 的頭像
榮譽勳章
UID - 582
在線等級: 級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時
註冊日期: 2002-12-06
VIP期限: 2007-04
住址: MIB總部
文章: 412
精華: 0
現金: 499 金幣
資產: 499 金幣
預設

3. Functions
Contents:
Perl Functions by Category
Perl Functions in Alphabetical Order



This chapter describes each of the Perl functions. They're presented one by one in alphabetical order. (Well, actually, some related functions are presented in pairs, or even threes or fours. This is usually the case when the Perl functions simply make UNIX system calls or C library calls. In such cases, the presentation of the Perl function matches up with the corresponding UNIX manpage organization.)

Each function description begins with a brief presentation of the syntax for that function. Parameters in ALL_CAPS represent placeholders for actual expressions, as described in the body of the function description. Some parameters are optional; the text describes the default values used when the parameter is not included.

The functions described in this chapter can serve as terms in an expression, along with literals and variables. (Or you can think of them as prefix operators. We call them operators half the time anyway.) Some of these operators, er, functions take a LIST as an argument. Such a list can consist of any combination of scalar and list values, but any list values are interpolated as a sequence of scalar values; that is, the overall argument LIST remains a single-dimensional list value. (To interpolate an array as a single element, you must explicitly create and interpolate a reference to the array instead.) Elements of the LIST should be separated by commas (or by =>, which is just a funny kind of comma). Each element of the LIST is evaluated in a list context.

The functions described in this chapter may be used either with or without parentheses around their arguments. (The syntax descriptions omit the parentheses.) If you use the parentheses, the simple (but occasionally surprising) rule is this: if it looks like a function, it is a function, and precedence doesn't matter. Otherwise it's a list operator or unary operator, and precedence does matter. And whitespace between the function and its left parenthesis doesn't count--so you need to be careful sometimes:


print 1+2+3; # Prints 6.
print(1+2) + 3; # Prints 3.
print (1+2)+3; # Also prints 3!
print +(1+2)+3; # Prints 6.
print ((1+2)+3); # Prints 6.

If you run Perl with the -w switch it can warn you about this. For example, the third line above produces:


print (...) interpreted as function at - line 3.
Useless use of integer addition in void context at - line 3.

Some of the LIST operators impose special semantic significance on the first element or two of the list. For example, the chmod function requires that the first element of the list be the new permission to apply to the files listed in the remaining elements. Syntactically, however, the argument to chmod is really just a LIST, and you could say:


unshift @array,0644;
chmod @array;

which is the same as:


chmod 0644, @array;

In these cases, the syntax summary at the top of the section mentions only the bare LIST, and any special initial arguments are documented in the description.

On the other hand, if the syntax summary lists any arguments before the LIST, those arguments are syntactically distinguished (not just semantically distinguished), and may impose syntactic constraints on the actual arguments you pass to the function when you call it. For instance, the first argument to the push function must be an array name. (You may also put such syntactic constraints on your own subroutine declarations by the use of prototypes. See "Prototypes" in Chapter 2, The Gory Details.)

Many of these operations are based directly on the C library's functions. If so, we do not attempt to duplicate the UNIX system documentation for that function, but refer you directly to the manual page. Such references look like this: "See getlogin (3)." The number in parentheses tells you which section of the UNIX manual normally contains the given entry. If you can't find a manual page (manpage for short) for a particular C function on your system, it's likely that the corresponding Perl function is unimplemented. For example, not all systems implement socket (2) calls. If you're running in the MS-DOS world, you may have socket calls, but you won't have fork (2). (You probably won't have manpages either, come to think of it.)

Occasionally you'll find that the documented C function has more arguments than the corresponding Perl function. The missing arguments are almost always things that Perl already knows, such as the length of the previous argument, so you needn't supply them in Perl. Any remaining disparities are due to different ways Perl and C specify their filehandles and their success/failure values.

For functions that can be used in either scalar or list context, non-abortive failure is generally indicated in a scalar context by returning the undefined value, and in a list context by returning the null list. Successful execution is generally indicated by returning a value that will evaluate to true (in context).

Remember the following rule: there is no general rule for converting a list into a scalar!

Many operators can return a list in list context. Each such operator knows whether it is being called in scalar or list context, and in scalar context returns whichever sort of value it would be most appropriate to return. Some operators return the length of the list that would have been returned in list context. Some operators return the first value in the list. Some operators return the last value in the list. Some operators return the "other" value, when something can be looked up either by number or by name. Some operators return a count of successful operations. In general, Perl operators do exactly what you want, unless you want consistency.

3.1 Perl Functions by Category
Here are Perl's functions and function-like keywords, arranged by category. Some functions appear under more than one heading.


Scalar manipulation

chomp, chop, chr, crypt, hex, index, lc, lcfirst, length, oct, ord, pack, q//, qq//, reverse, rindex, sprintf, substr, tr///, uc, ucfirst, y///


Regular expressions and pattern matching

m//, pos, quotemeta, s///, split, study


Numeric functions

abs, atan2, cos, exp, hex, int, log, oct, rand, sin, sqrt, srand


Array processing

pop, push, shift, splice, unshift


List processing

grep, join, map, qw//, reverse, sort, unpack


Hash processing

delete, each, exists, keys, values


Input and output

binmode, close, closedir, dbmclose, dbmopen, die, eof, fileno, flock, format, getc, print, printf, read, readdir, rewinddir, seek, seekdir, select (ready file descriptors), syscall, sysread, syswrite, tell, telldir, truncate, warn, write


Fixed-length data and records

pack, read, syscall, sysread, syswrite, unpack, vec


Filehandles, files, and directories

chdir, chmod, chown, chroot, fcntl, glob, ioctl, link, lstat, mkdir, open, opendir, readlink, rename, rmdir, stat, symlink, sysopen, umask, unlink, utime


Flow of program control

caller, continue, die, do, dump, eval, exit, goto, last, next, redo, return, sub, wantarray


Scoping

caller, import, local, my, package, use


Miscellaneous

defined, dump, eval, formline, local, my, reset, scalar, undef, wantarray


Processes and process groups

alarm, exec, fork, getpgrp, getppid, getpriority, kill, pipe, qx//, setpgrp, setpriority, sleep, system, times, wait, waitpid


Library modules

do, import, no, package, require, use


Classes and objects

bless, dbmclose, dbmopen, package, ref, tie, tied, untie, use


Low-level socket access

accept, bind, connect, getpeername, getsockname, getsockopt, listen, recv, send, setsockopt, shutdown, socket, socketpair


System V interprocess communication

msgctl, msgget, msgrcv, msgsnd, semctl, semget, semop, shmctl, shmget, shmread, shmwrite


Fetching user and group information

endgrent, endhostent, endnetent, endpwent, getgrent, getgrgid, getgrnam, getlogin, getpwent, getpwnam, getpwuid, setgrent, setpwent


Fetching network information

endprotoent, endservent, gethostbyaddr, gethostbyname, gethostent, getnetbyaddr, getnetbyname, getnetent, getprotobyname, getprotobynumber, getprotoent, getservbyname, getservbyport, getservent, sethostent, setnetent, setprotoent, setservent


Time

gmtime, localtime, time, times
mic64 目前離線  
送花文章: 0, 收花文章: 21 篇, 收花: 61 次
舊 2004-05-20, 01:08 PM   #5 (permalink)
註冊會員
 
mic64 的頭像
榮譽勳章
UID - 582
在線等級: 級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時
註冊日期: 2002-12-06
VIP期限: 2007-04
住址: MIB總部
文章: 412
精華: 0
現金: 499 金幣
資產: 499 金幣
預設

4. References and Nested Data Structures
Contents:
What Is a Reference?
Creating Hard References
Using Hard References
Symbolic References
Braces, Brackets, and Quoting
A Brief Tutorial: Manipulating Lists of Lists
Data Structure Code Examples



For both practical and philosophical reasons, Perl has always been biased in favor of flat, linear data structures. And for many problems, this is exactly what you want. But occasionally you need to set up something just a little more complicated and hierarchical. Under older versions of Perl you could construct complex data structures indirectly by using eval or typeglobs.

Suppose you wanted to build a simple table (two-dimensional array) showing vital statistics--say, age, eye color, and weight--for a group of people. You could do this by first creating an array for each individual:



@john = (47, "brown", 186);
@mary = (23, "hazel", 128);
@bill = (35, "blue", 157);

and then constructing a single, additional array consisting of the names of the other arrays:


@vitals = ('john', 'mary', 'bill');

Unfortunately, actually using this table as a two-dimensional data structure is cumbersome. To change John's eyes to "red" after a night on the town, you'd have to say something like:


$vitals = $vitals[0];
eval "\$${vitals}[1] = 'red'";

A much more efficient (but not more readable) way to do the same thing is to use a typeglob assignment to temporarily alias one symbol table entry to another:


local(*array) = $vitals[0]; # Alias *array to *john.
$array[1] = 'red'; # Actually sets $john[1].

Alternatively, you could avoid the symbol table altogether by doing everything with a set of parallel hash arrays, emulating pointers symbolically by doing key lookups in the appropriate hash. Finally, you could define all your structures operationally, using pack and unpack, or join and split.

So even though you could use a variety of techniques to emulate pointers and data structures, all of them could get to be unwieldy. To be sure, Perl still supports these older mechanisms, since they remain quite useful for simple problems. But now Perl also supports references.

4.1 What Is a Reference?
In the preceding example using eval, $vitals[0] had the value 'john'. That is, it happened to contain a string that was also the name for another variable. You could say that the first variable referred to the second. We will speak of this sort of reference as a symbolic reference. You can think of it as analogous to symbolic links in UNIX filesystems. Perl now provides some simplified mechanisms for using symbolic references; in particular, the need for an eval or a typeglob assignment in our example disappears. See "Symbolic References" later in this chapter.

The other kind of reference is the hard reference.[1] A hard reference refers not to the name of another variable (which is just a container for a value) but rather to an actual value, some internal glob of data, which we will call a "thingy", in honor of that thingy that hangs down in the back of your throat. (You may also call it a "referent", if you prefer to live a joyless existence.) Suppose, for example, that you create a hard reference to the thingy contained in the variable @array. This hard reference and the thingy it refers to will continue to exist even after @array goes out of scope. Only when the reference count of the thingy itself goes to zero is the thingy actually destroyed.

[1] If you like, you can think of hard references as real references, and symbolic references as fake references. It's like the difference between real friendship and mere name-dropping.

To put it another way, a Perl variable lives in a symbol table and holds one hard reference to its underlying thingy (which may be a simple thingy like a number, or a complex thingy like an array or hash, but there's still only one reference from the variable to the value). There may be other hard references to the same thingy, but if so, the variable doesn't know (or care) about them. A symbolic reference names another variable, so there's always a named location involved, but a hard reference just points to a thingy. It doesn't know (or care) whether there are any other references to the thingy, or whether any of those references are through variables. Hence, a hard reference can refer to an anonymous thingy. All such anonymous thingies are accessed through hard references. But the converse is not necessarily true--just because something has a hard reference to it doesn't necessarily mean it's anonymous. It might have another reference through a named variable. (It can even have more than one name, if it is aliased with typeglobs.)

To reference a variable, in the terminology of this chapter, is to create a hard reference to the thingy underlying the variable. (There's a special operator to do this creative act.) The hard reference so created is simply a scalar value, which behaves in all familiar contexts just like any other scalar value should. To dereference this scalar value is to use it to refer back to the original thingy, as you must do when reading or writing to the thingy. Both referencing and dereferencing occur only when you invoke certain explicit mechanisms; no implicit referencing or dereferencing occurs in Perl.[2][3]

[2] Actually, a function with a prototype can use implicit pass-by-reference if explicitly declared that way. If so, then the caller of the function doesn't need to know he's passing a reference, but you still have to dereference it explicitly within the function. See Chapter 2, The Gory Details.

[3] Actually, to be perfectly honest, there's also some mystical automatic dereferencing when you use certain kinds of filehandles, but that's for backward compatibility, and is transparent to the casual user.

Any scalar may hold a hard reference, and such a reference may point to any data structure. Since arrays and hashes contain scalars, you can build arrays of arrays, arrays of hashes, hashes of arrays, arrays of hashes and functions, and so on.

Keep in mind, though, that Perl arrays and hashes are internally one-dimensional. They can only hold scalar values (strings, numbers, and references). When we use a phrase like "array of arrays", we really mean "array of references to arrays". But since that's the only way to implement an array of arrays in Perl, it follows that the shorter, less accurate phrase is not so inaccurate as to be false, and therefore should not be totally despised, unless you're into that sort of thing.
mic64 目前離線  
送花文章: 0, 收花文章: 21 篇, 收花: 61 次
舊 2004-05-20, 01:10 PM   #6 (permalink)
註冊會員
 
mic64 的頭像
榮譽勳章
UID - 582
在線等級: 級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時
註冊日期: 2002-12-06
VIP期限: 2007-04
住址: MIB總部
文章: 412
精華: 0
現金: 499 金幣
資產: 499 金幣
預設

6. Social Engineering
Contents:
Cooperating with Command Interpreters
Cooperating with Other Processes
Cooperating with Strangers
Cooperating with Other Languages



Languages have different personalities. You can classify computer languages by how introverted or extroverted they are; for instance, Icon and Lisp are stay-at-home languages, while Tcl and the various shells are party animals. Self-sufficient languages prefer to compete with other languages, while social languages prefer to cooperate with other languages. As usual, Perl tries to do both.

So this chapter is about relationships. Until now we've looked inward at the competitive nature of Perl, but now we need to look outward and see the cooperative nature of Perl. If we really mean what we say about Perl being a glue language, then we can't just talk about glue; we have to talk about the various kinds of things you can glue together. A glob of glue by itself isn't very interesting.

Perl doesn't just glue together other computer languages. It also glues together command line interpreters, operating systems, processes, machines, devices, networks, databases, institutions, cultures, Web pages, GUIs, peers, servers, and clients, not to mention people like system administrators, users, and of course, hackers, both naughty and nice. In fact, Perl is rather competitive about being cooperative.

So this chapter is about Perl's relationship with everything in the world. Obviously, we can't talk about everything in the world, but we'll try.

6.1 Cooperating with Command Interpreters
It is fortunate that Perl grew up in the UNIX world--that means its invocation syntax works pretty well under the command interpreters of other operating systems too. Most command interpreters know how to deal with a list of words as arguments, and don't care if an argument starts with a minus sign. There are, of course, some sticky spots where you'll get fouled up if you move from one system to another. You can't use single quotes under MS-DOS as you do under UNIX, for instance. And on systems like VMS, some wrapper code has to jump through hoops to emulate UNIX I/O redirection. Once you get past those issues, however, Perl treats its switches and arguments much the same on any operating system.

Even when you don't have a command interpreter, per se, it's easy to execute a Perl script from another program, such as the inet daemon or a CGI server. Not only can such a server pass arguments in the ordinary way, but it can also pass in information via environment variables and (under UNIX at least) inherited file descriptors. Even more exotic argument-passing mechanisms may be encapsulated in a module that can be brought into the Perl script via a simple use directive.

Command Processing
Perl parses command-line switches in the standard fashion.[1] That is, it expects any switches (words beginning with a minus) to come first on the command line. After that comes the name of the script (usually), followed by any additional arguments (often filenames) to be passed into the script. Some of these additional arguments may be switches, but if so, they must be processed by the script, since Perl gives up parsing switches as soon as it sees a non-switch, or the special "- -" switch that terminates switch processing.

[1] Presuming you agree that UNIX is both standard and fashionable.

Perl gives you some flexibility in how you supply your program. For small, quick-and-dirty jobs, you can program Perl entirely from the command line. For larger, more permanent jobs, you can supply a Perl script as a separate file. Perl looks for the script to be specified in one of three ways:


Specified line by line via -e switches on the command line.

Contained in the file specified by the first filename on the command line. (Note that systems supporting the #! shebang notation invoke interpreters this way on your behalf.)

Passed in implicitly via standard input. This only works if there are no filename arguments; to pass arguments to a standard-input script you must explicitly specify a "-" for the script name. For example, under UNIX:

echo "print 'Hello, world'" | perl -

With methods 2 and 3, Perl starts parsing the input file from the beginning, unless you've specified a -x switch, in which case it scans for the first line starting with #! and containing the word "perl", and starts there instead. This is useful for running a script embedded in a larger message. (In this case you might indicate the end of the script using the _ _END_ _ token.)


Whether or not you use -x, the #! line is always examined for switches as the line is being parsed. Thus, if you're on a machine that only allows one argument with the #! line, or worse, doesn't even recognize the #! line as special, you still can get consistent switch behavior regardless of how Perl was invoked, even if -x was used to find the beginning of the script.


WARNING:


Because many versions of UNIX silently chop off kernel interpretation of the #! line after 32 characters, some switches may be passed in on the command line, and some may not; you could even get a "-" without its letter, if you're not careful. You probably want to make sure that all your switches fall either before or after that 32-character boundary. Most switches don't actually care if they're processed redundantly, but getting a "-" instead of a complete switch could cause Perl to try to execute standard input instead of your script. And a partial -I switch could also cause odd results. Of course, if you're not on a UNIX system, you're guaranteed not to have this problem.


Parsing of the switches on the #! line starts wherever "perl" is mentioned in the line. The sequences "-*" and "- " are specifically ignored for the benefit of emacs users, so that, if you're so inclined, you can say:


#!/bin/sh -- # -*- perl -*- -p
eval 'exec perl -S $0 ${1+"$@"}'
if 0;

and Perl will see only the -p switch. The fancy "-*- perl -*-" gizmo tells emacs to start up in Perl mode; you don't need it if you don't use emacs. The -S mess is explained below.

If the #! line does not contain the word "perl", the program named after the #! is executed instead of the Perl interpreter. For example, suppose you have an ordinary Bourne shell script out there that says:


#!/bin/sh
echo "I am a shell script"

If you feed that file to Perl, then Perl will run /bin/sh for you. This is slightly bizarre, but it helps people on machines that don't recognize #!, because--by setting their SHELL environmental variable--they can tell a program (such as a mailer) that their shell is /usr/bin/perl, and Perl will then dispatch the program to the correct interpreter for them, even though their kernel is too stupid to do so. Classify it as a strange form of cooperation.

But back to Perl scripts that are really Perl scripts. After locating your script, Perl compiles the entire script to an internal form. If any compilation errors arise, execution of the script is not attempted (unlike the typical shell script, which might run partway through before finding a syntax error). If the script is syntactically correct, it is executed. If the script runs off the end without hitting an exit or die operator, an implicit exit(0) is provided to indicate successful completion.

Switches
A single-character switch with no argument may be combined (bundled) with the following switch, if any.


#!/usr/bin/perl -spi.bak # same as -s -p -i.bak

Switches are also known as options, or flags. Perl recognizes these switches:


- -

Terminates switch processing, even if the next argument starts with a minus. It has no other effect.


-0[octnum]

Specifies the record separator ($/) as an octal number. If octnum is not present, the null character is the separator. Other switches may precede or follow the octal number. For example, if you have a version of find (1) that can print filenames terminated by the null character, you can say this:


find . -name '*.bak' -print0 | perl -n0e unlink

The special value 00 will cause Perl to slurp files in paragraph mode, equivalent to setting the $/ variable to "". The value 0777 will cause Perl to slurp files whole since there is no legal ASCII character with that value. This is equivalent to undefining the $/ variable.


-a

Turns on autosplit mode when used with a -n or -p. An implicit split command to the @F array is done as the first thing inside the implicit while loop produced by the -n or -p. So:


perl -ane 'print pop(@F), "\n";'

is equivalent to:


while (<>) {
@F = split(' ');
print pop(@F), "\n";
}

A different field delimiter may be specified using -F.


-c

Causes Perl to check the syntax of the script and then exit without executing it. Actually, it will execute any BEGIN blocks and use directives, since these are considered to occur before the execution of your program. It also executes any END blocks, in case they need to clean up something that happened in a corresponding BEGIN block. The switch is more or less equivalent to having an exit(0) as the first statement in your program.


-d

Runs the script under the Perl debugger. See "The Perl Debugger" in Chapter 8, Other Oddments.


-d:foo

Runs the script under the control of a debugging or tracing module installed in the Perl library as Devel::foo. For example, -dProf executes the script using the Devel:Prof profiler. See also the debugging section in Chapter 8, Other Oddments.


-Dnumber
-Dlist

Sets debugging flags. (This only works if debugging is compiled into your version of Perl via the -DDEBUGGING C compiler switch.) You may specify either a number that is the sum of the bits you want, or a list of letters. To watch how it executes your script, for instance, use -D14 or -Dslt. Another nice value is -D1024 or -Dx, which lists your compiled syntax tree. And -D512 or -Dr displays compiled regular expressions. The numeric value is available internally as the special variable $^D. Here are the assigned bit values:

Bit Letter Meaning
1 p Tokenizing and parsing
2 s Stack snapshots
4 l Label stack processing
8 t Trace execution
16 o Object method Lookup
32 c String/numeric conversions
64 P Print preprocessor command for -P
128 m Memory allocation
256 f Format processing
512 r Regular expression processing
1,024 x Syntax tree dump
2,048 u Tainting checks
4,096 L Memory leaks (not supported any more)
8,192 H Hash dump - - usurps values()
16,384 X Scratchpad allocation
32,768 D Cleaning up




-e commandline

May be used to enter one or more lines of script. If -e is used, Perl will not look for a script filename in the argument list. The -e argument is treated as if it ends with a newline, so multiple -e commands may be given to build up a multi-line script. (Make sure to use semicolons where you would in a normal program.) Just because -e supplies a newline on each argument doesn't mean you have to use multiple -e switches--if your shell supports multi-line quoting, you may pass a multi-line script as one -e argument, just as awk (1) scripts are typically passed.


-Fpattern

Specifies the pattern to split on if -a is also in effect. The pattern may be surrounded by //, "" or ' ' , otherwise it will be put in single quotes. (Remember that to pass quotes through a shell, you have to quote the quotes.)


-h

Prints a summary of Perl's command-line options.


-i[extension]

Specifies that files processed by the < > construct are to be edited in-place. It does this by renaming the input file, opening the output file by the original name, and selecting that output file as the default for print statements. The extension, if supplied, is added to the name of the old file to make a backup copy. If no extension is supplied, no backup is made. From the shell, saying:


$ perl -p -i.bak -e "s/foo/bar/; ... "

is the same as using the script:


#!/usr/bin/perl -pi.bak
s/foo/bar/;

which is equivalent to:


#!/usr/bin/perl
while (<>) {
if ($ARGV ne $oldargv) {
rename($ARGV, $ARGV . '.bak');
open(ARGVOUT, ">$ARGV");
select(ARGVOUT);
$oldargv = $ARGV;
}
s/foo/bar/;
}
continue {
print; # this prints to original filename
}
select(STDOUT);

except that the -i form doesn't need to compare $ARGV to $oldargv to know when the filename has changed. It does, however, use ARGVOUT for the selected filehandle. Note that STDOUT is restored as the default output filehandle after the loop. You can use eof without parentheses to locate the end of each input file, in case you want to append to each file, or reset line numbering (see the examples of eof in Chapter 3, Functions).


-Idirectory

Directories specified by -I are prepended to @INC, which holds the search path for modules. -I also tells the C preprocessor where to search for include files. The C preprocessor is invoked with -P; by default it searches /usr/include and /usr/lib/perl. Unless you're going to be using the C preprocessor (and almost no one does any more), you're better off using the use lib directive within your script.


-l[octnum]

Enables automatic line-end processing. It has two effects: first, it automatically chomps the line terminator when used with -n or -p, and second, it sets $\ to the value of octnum so any print statements will have a line terminator of ASCII value octnum added back on. If octnum is omitted, sets $\ to the current value of $/, typically newline. So, to trim lines to 80 columns, say this:


perl -lpe 'substr($_, 80) = ""'

Note that the assignment $\ = $/ is done when the switch is processed, so the input record separator can be different from the output record separator if the -l switch is followed by a -0 switch:


gnufind / -print0 | perl -ln0e 'print "found $_" if -p'

This sets $\ to newline and later sets $/ to the null character. (Note that 0 would have been interpreted as part of the -l switch had it followed the -l directly. That's why we bundled the -n switch between them.)


-m[-]module



-M[-]module



-M[-]'module ...'



-[mM][-]module=arg [ ,arg ] ...



-mmodule

Executes use module() before executing your script.


-Mmodule

Executes use module before executing your script. The command is formed by mere interpolation, so you can use quotes to add extra code after the module name, for example, -M'module qw(foo bar)'. If the first character after the -M or -m is a minus (-), then the use is replaced with no.

A little built-in syntactic sugar means you can also say -mmodule=foo,bar or -Mmodule=foo,bar as a shortcut for -M'module qw(foo bar)'. This avoids the need to use quotes when importing symbols. The actual code generated by -Mmodule=foo,bar is:


use module split(/,/, q{foo, bar})

Note that the = form removes the distinction between -m and -M.


-n

Causes Perl to assume the following loop around your script, which makes it iterate over filename arguments rather as sed -n or awk do:


LINE:
while (<>) {
... # your script goes here
}

Note that the lines are not printed by default. See -p to have lines printed. Here is an efficient way to delete all files older than a week, assuming you're on UNIX:


find . -mtime +7 -print | perl -nle unlink

This is faster than using the -exec switch of find (1) because you don't have to start a process on every filename found. By an amazing coincidence, BEGIN and END blocks may be used to capture control before or after the implicit loop, just as in awk.


-p

Causes Perl to assume the following loop around your script, which makes it iterate over filename arguments rather as sed does:


LINE:
while (<>) {
... # your script goes here
} continue {
print;
}

Note that the lines are printed automatically. To suppress printing use the -n switch. A -p overrides a -n switch. By yet another amazing coincidence, BEGIN and END blocks may be used to capture control before or after the implicit loop, just as in awk.


-P

Causes your script to be run through the C preprocessor before compilation by Perl. (Since both comments and cpp (1) directives begin with the # character, you should avoid starting comments with any words recognized by the C preprocessor such as "if", "else" or "define".)


-s

Enables some rudimentary switch parsing for switches on the command line after the script name but before any filename arguments or "- -" switch terminator. Any switch found there is removed from @ARGV, and a variable of the same name as the switch is set in the Perl script. No switch bundling is allowed, since multi-character switches are allowed. The following script prints "true" if and only if the script is invoked with a -xyz switch.


#!/usr/bin/perl -s
if ($xyz) { print "true\n"; }

If the switch in question is followed by an equals sign, the variable is set to whatever follows the equals sign in that argument. The following script prints "true" if and only if the script is invoked with a -xyz=abc switch.


#!/usr/bin/perl -s
if ($xyz eq 'abc') { print "true\n"; }



-S

Makes Perl use the PATH environment variable to search for the script (unless the name of the script starts with a slash). Typically this is used to emulate #! startup on machines that don't support #!, in the following manner:


#!/usr/bin/perl
eval "exec /usr/bin/perl -S $0 $*"
if $running_under_some_shell;

The system ignores the first line and feeds the script to /bin/sh, which proceeds to try to execute the Perl script as a shell script. The shell executes the second line as a normal shell command, and thus starts up the Perl interpreter. On some systems $0 doesn't always contain the full pathname, so -S tells Perl to search for the script if necessary. After Perl locates the script, it parses the lines and ignores them because the variable $running_under_some_shell is never true. A better construct than $* would be ${1+`$@`}, which handles embedded spaces and such in the filenames, but doesn't work if the script is being interpreted by csh. In order to start up sh rather than csh, some systems have to replace the #! line with a line containing just a colon, which Perl will politely ignore. Other systems can't control that, and need a totally devious construct that will work under any of csh, sh, or perl, such as the following:


eval '(exit $?0)' && eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
& eval 'exec /usr/bin/perl -S $0 $argv:q'
if 0;

Yes, it's ugly, but so are the systems that work[2] this way.

[2] We use the term advisedly.


-T

Forces "taint" checks to be turned on so you can test them. Ordinarily these checks are done only when running setuid or setgid. It's a good idea to turn them on explicitly for programs run on another's behalf, such as CGI programs. See "Cooperating with Strangers" later in this chapter.


-u

Causes Perl to dump core after compiling your script. You can then take this core dump and turn it into an executable file by using the undump program (not supplied). This speeds startup at the expense of some disk space (which you can minimize by stripping the executable). If you want to execute a portion of your script before dumping, use Perl's dump operator instead. Note: availability of undump is platform specific; it may not be available for a specific port of Perl.


-U

Allows Perl to do unsafe operations. Currently the only "unsafe" operations are the unlinking of directories while running as superuser, and running setuid programs with fatal taint checks turned into warnings.


-v

Prints the version and patchlevel of your Perl executable.


-V

Prints a summary of the major Perl configuration values and the current value of @INC.


-V:name

Prints to STDOUT the value of the named configuration variable.


-w

Prints warnings about identifiers that are mentioned only once, and scalar variables that are used before being set. Also warns about redefined subroutines, and references to undefined filehandles or filehandles opened read-only that you are attempting to write on. Also warns you if you use a non-number as though it were a number, or if you use an array as though it were a scalar, or if your subroutines recurse more than 100 deep, and innumerable other things. See every entry labeled (W) in Chapter 9, Diagnostic Messages.


-xdirectory

Tells Perl to extract a script that is embedded in a message. Leading garbage will be discarded until the first line that starts with #! and contains the string "perl". Any meaningful switches on that line after the word "perl" will be applied. If a directory name is specified, Perl will switch to that directory before running the script. The -x switch only controls the disposal of leading garbage. The script must be terminated with _ _END_ _ or _ _DATA_ _ if there is trailing garbage to be ignored. (The script can process any or all of the trailing garbage via the DATA filehandle if desired.)
mic64 目前離線  
送花文章: 0, 收花文章: 21 篇, 收花: 61 次
舊 2004-05-20, 01:11 PM   #7 (permalink)
註冊會員
 
mic64 的頭像
榮譽勳章
UID - 582
在線等級: 級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時
註冊日期: 2002-12-06
VIP期限: 2007-04
住址: MIB總部
文章: 412
精華: 0
現金: 499 金幣
資產: 499 金幣
預設

7. The Standard Perl Library
Contents:
Beyond the Standard Library
Library Modules



This chapter describes the collection of Perl code that comes along with the Perl distribution. If you use this library and then share your program with others, they will not have to take special steps to execute the program, because the same library is available to Perl programs everywhere.

You'll save some time if you make the effort to get familiar with the standard library. There's no point in reinventing the wheel. You should be aware, however, that the library contains a wide range of material. While some modules may be extremely helpful, others may be completely irrelevant to your needs. For example, some are useful only if you are creating extensions to Perl. We offer below a rough classification of the library modules to aid you in browsing.

First, however, let's untangle some terminology:


package

A package is a simple namespace management device, allowing two different parts of a Perl program to have a (different) variable named $fred. These namespaces are managed with the package declaration, described in Chapter 5, Packages, Modules, and Object Classes.


library

A library is a set of subroutines for a particular purpose. Often the library declares itself a separate package so that related variables and subroutines can be kept together, and so that they won't interfere with other variables in your program. Generally, a library is placed in a separate file, often ending in ".pl ", and then pulled into the main program via require. (This mechanism has largely been superseded by the module mechanism, so nowadays we often use the term "library" to talk about the whole system of modules that come with Perl. See the title of this chapter, for instance.)


module

A module is a library that conforms to specific conventions, allowing the file to be brought in with a use directive at compile time. Module filenames end in ".pm", because the use directive insists on that. (It also translates the subpackage delimiter :: to whatever your subdirectory delimiter is; it is / on UNIX.) Chapter 5, Packages, Modules, and Object Classes describes Perl modules in greater detail.


pragma

A pragma is a module that affects the compilation phase of your program as well as the execution phase. Think of them as hints to the compiler. Unlike modules, pragmas often (but not always) limit the scope of their effects to the innermost enclosing block of your program. The names of pragmas are by convention all lowercase.

For easy reference, this chapter is arranged alphabetically. If you wish to look something up by functional grouping, Tables 7-1 through 7-11 display an (admittedly arbitrary) listing of the modules and pragmas described in this chapter.


Table 7.1: General Programming: Miscellaneous Module Function
Benchmark Check and compare running times of code
Config Access Perl configuration information
Env Import environment variables
English Use English or awk names for punctuation variables
Getopt::Long Extended processing of command-line options
Getopt::Std Process single-character switches with switch clustering
lib Manipulate @INC at compile time
Shell Run shell commands transparently within Perl
strict Restrict unsafe constructs
Symbol Generate anonymous globs; qualify variable names
subs Predeclare subroutine names
vars Predeclare global variable names



Table 7.2: General Programming: Error Handling and Logging Module Function
Carp Generate error messages
diagnostics Force verbose warning diagnostics
sigtrap Enable stack backtrace on unexpected signals
Sys::Syslog Perl interface to UNIX syslog (3) calls



Table 7.3: General Programming: File Access and Handling Module Function
Cwd Get pathname of current working directory
DirHandle Supply object methods for directory handles
File::Basename Parse file specifications
File::CheckTree Run many tests on a collection of files
File::Copy Copy files or filehandles
File::Find Traverse a file tree
File::Path Create or remove a series of directories
FileCache Keep more files open than the system permits
FileHandle Supply object methods for filehandles
SelectSaver Save and restore selected filehandle



Table 7.4: General Programming: Text Processing and Screen Interfaces Module Function
Pod::Text Convert POD data to formatted ASCII text
Search:ict Search for key in dictionary file
Term::Cap Terminal capabilities interface
Term::Complete Word completion module
Text::Abbrev Create an abbreviation table from a list
Text::ParseWords Parse text into a list of tokens
Text::Soundex The Soundex Algorithm described by Knuth
Text::Tabs Expand and unexpand tabs
Text::Wrap Wrap text into a paragraph



Table 7.5: Database Interfaces Module Function
AnyDBM_File Provide framework for multiple DBMs
DB_File Tied access to Berkeley DB
GDBM_File Tied access to GDBM library
NDBM_File Tied access to NDBM files
ODBM_File Tied access to ODBM files
SDBM_File Tied access to SDBM files



Table 7.6: Mathematics Module Function
integer Do arithmetic in integer instead of double
Math::BigFloat Arbitrary-length floating-point math package
Math::BigInt Arbitrary-length integer math package
Math::Complex Complex numbers package



Table 7.7: Networking and Interprocess Communication Module Function
IPC::Open2 Open a process for both reading and writing
IPC::Open3 Open a process for reading, writing, and error handling
Net::Ping Check whether a host is online
Socket Load the C socket.h defines and structure manipulators
Sys::Hostname Try every conceivable way to get hostname



Table 7.8: Time and Locale Module Function
Time::Local Efficiently compute time from local and GMT time
I18N::Collate Compare 8-bit scalar data according to the current locale



Table 7.9: For Developers: Autoloading and Dynamic Loading Module Function
AutoLoader Load functions only on demand
AutoSplit Split a module for autoloading
Devel::SelfStubber Generate stubs for a SelfLoading module
DynaLoader Automatic dynamic loading of Perl modules
SelfLoader Load functions only on demand



Table 7.10: For Developers: Language Extensions and Platform Development Support Module Function
ExtUtils::Install Install files from here to there
ExtUtils::Liblist Determine libraries to use and how to use them
ExtUtils::MakeMaker Create a Makefile for a Perl extension
ExtUtils::Manifest Utilities to write and check a MANIFEST file
ExtUtils::Miniperl Write the C code for perlmain.c
ExtUtils::Mkbootstrap Make a bootstrap file for use by DynaLoader
ExtUtils::Mksymlists Write linker option files for dynamic extension
ExtUtils::MM_OS2 Methods to override UNIX behavior in ExtUtils::MakeMaker
ExtUtils::MM_Unix Methods used by ExtUtils::MakeMaker
ExtUtils::MM_VMS Methods to override UNIX behavior in ExtUtils::MakeMaker
Fcntl Load the C fcntl.h defines
POSIX Interface to IEEE Std 1003.1
Safe Create safe namespaces for evaluating Perl code
Test::Harness Run Perl standard test scripts with statistics



Table 7.11: For Developers: Object-Oriented Programming Support Module Function
Exporter Default import method for modules
overload Overload Perl's mathematical operations
Tie::Hash Base class definitions for tied hashes
Tie::Scalar Base class definitions for tied scalars
Tie::StdHash Base class definitions for tied hashes
Tie::StdScalar Base class definitions for tied scalars
Tie::SubstrHash Fixed-table-size, fixed-key-length hashing


7.1 Beyond the Standard Library
If you don't find an entry in the standard library that fits your needs, it's still quite possible that someone has written code that will be useful to you. There are many superb library modules that are not included in the standard distribution, for various practical, political, and pathetic reasons. To find out what is available, you can look at the Comprehensive Perl Archive Network (CPAN). See the discussion of CPAN in the Preface.

Here are the major categories of modules available from CPAN:


Archiving and Compression

Authentication, Security and Encryption

Control Flow Utilities (callbacks, exceptions, and so on)

Data Types and Data Type Utilities

Database Interfaces

Development Support

Filehandle and Input/Output Stream Utilities

File Names, File Systems and File Locking

Images, Pixmap and Bitmap Manipulation, Drawing and Graphing

Interfaces to/Emulations of Other Programming Languages

Internationalization and Locale

Language Extensions and Documentation Tools

Mail and Usenet News

Miscellaneous Modules

Networking, Device Control (modems) and Inter-process Communication

Operating System Interfaces

Option, Argument, Parameter and Configuration File Processing

Server and Daemon Utilities

String Processing, Language Text Processing, Parsing and Searching

User Interfaces

World Wide Web, HTML, HTTP, CGI, MIME

Allow us again to reiterate once more that these things are in a state of flux, and you will certainly find more and better stuff on CPAN than we can possibly describe here. The Perl of Great Price has outgrown its oyster, so to speak, because Perl is truly a community effort these days--see John 14:12.
mic64 目前離線  
送花文章: 0, 收花文章: 21 篇, 收花: 61 次
舊 2004-05-20, 01:12 PM   #8 (permalink)
註冊會員
 
mic64 的頭像
榮譽勳章
UID - 582
在線等級: 級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時
註冊日期: 2002-12-06
VIP期限: 2007-04
住址: MIB總部
文章: 412
精華: 0
現金: 499 金幣
資產: 499 金幣
預設

8. Other Oddments
Contents:
The Perl Debugger
Common Goofs for Novices
Efficiency
Programming with Style
Distribution and Installation
Perl Poetry
History Made Practical



Did you ever have a junk drawer? You know, one of those drawers where you put everything important enough to keep (like the spare key to the back door), but not important enough to have a place of its own (like the back door itself).

Well, this chapter is the junk drawer of the book. We stuffed many important (and a few not-so-important) things in this chapter. Read on.

8.1 The Perl Debugger
First of all, have you tried using the -w switch?

If you invoke Perl with the -d switch, your script runs under the Perl debugger. This works like an interactive Perl environment, prompting for debugger commands that let you examine source code, set breakpoints, dump out your function-call stack, change the values of variables, and so on. Any command not recognized by the debugger[1] is directly executed (eval'd) as Perl code in the current package.[2] This is so wonderfully convenient that you often fire up the debugger all by itself just to test out Perl constructs interactively to see what they do. Here's a common way to get that:

[1] Leading whitespace before a command would cause the debugger to think it's not a command for it, but rather for Perl, so be careful not to do that.

[2] The debugger uses the DB package for its own state information.


perl -d -e 42

In Perl, the debugger is not a separate program as it usually is in a typical programming environment. Instead, the -d flag tells the compiler to insert source information into the parse trees it's about to hand off to the interpreter. That means your code must first compile correctly for the debugger to work on it. Then when the interpreter starts up, it pre-loads a Perl library file containing the debugger itself.

Debugger Commands
The debugger understands the following commands:


h [command ]

Prints out a help message.

If you supply another debugger command as an argument to the h command, it prints out the description for just that command. The command "h h" produces a more compact help listing designed to fit on one screen. If the output of the h command (or any command, for that matter) scrolls past your screen, just precede the command with a leading pipe symbol so it's run through your pager:


DB<1> |h


p expr

Same as "print DB::OUT expr" in the current package. In particular, since this is just Perl's own print function, this means that nested data structures and objects are not dumped, unlike with the x command. The DB::OUT handle is opened to /dev/tty (or perhaps an editor window) no matter where standard output may have been redirected to.


x expr

Evals its expression in a list context and dumps out the result in a pretty-printed fashion. Nested data structures are printed out recursively, unlike with the print command above.


V [pkg [vars]]

Display all (or some) variables in package (defaulting to the main package) using a data pretty-printer. (Hashes show their keys and values so you see what's what, control characters are made printable, nested data structures print out in a legible fashion, and so on.) Make sure you type the identifiers without a type specifier such as $ or @, like this:


V DB filename line

In place of a variable name, you can use ~pattern or !pattern to print existing variables whose names either match or don't match the specified regular expression.


X [vars]

Same as V currentpackage [vars].


T

Produce a stack backtrace. See below for details on its output.


s [expr]

Single step. Executes until it reaches the beginning of another statement, descending into subroutine calls. If an expression is supplied that includes function calls, it, too, will be single-stepped.


n

Next. Executes over subroutine calls, until it reaches the beginning of the next statement at this same level.


<CR>

Repeat last n or s command.


c [line]

Continue, optionally inserting a one-time-only breakpoint at the specified line.


l

List next few lines.


l min+incr

List incr+1 lines starting at min.


l min-max

List lines min through max.


l line

List a single line.


l subname

List first few lines from subroutine.


-

List previous few lines.


w [line]

List window (a few lines) around the given line, or the current one if no line is supplied.


.

Return debugger pointer to the last-executed line and print it out.


f filename

Switch to viewing a different file.


/pattern/

Search forward for pattern; final / is optional.


?pattern?

Search backward for pattern; final ? is optional.


L

List all breakpoints and actions for the current file.


S [ [ ! ] pattern]

List subroutine names matching (or not matching with "!") pattern. If no pattern is given, all subroutines are listed.


t

Toggle trace mode.


t expr

Trace through execution of expr.


b [line] [condition]

Set a breakpoint at line. If line is omitted, set a breakpoint on the line that is about to be executed. condition, if given, is evaluated each time the statement is reached, and a breakpoint is taken only if condition is true. Breakpoints may only be set on lines that begin an executable statement. Conditions don't use if:


b 237 $x > 30
b 33 /pattern/i



b subname [condition]

Set a (possibly conditional) breakpoint at the first line of the named subroutine.


d [line]

Delete a breakpoint at the specified line. If line is omitted, deletes the breakpoint on the line that is about to be executed.


D

Delete all installed breakpoints.

a [line] command

Set an action to be done before the line is executed. The sequence of steps taken by the debugger is:


Check for a breakpoint at this line.

Print the line if necessary (tracing).

Do any actions associated with that line.

Prompt the user if at a breakpoint or in single-step.

Evaluate the line.

For example, this will print out $foo every time line 53 is passed:


a 53 print "DB FOUND $foo\n"



A

Delete all installed actions.


O [opt[=val]]

Set or query values of options. val defaults to 1. opt can be abbreviated to the shortest unique string, which is why some options are uppercase and others are lowercase. Options are:

Option Value
recallCommand ShellBang The characters used to recall command or spawn shell. By default, these are both set to "!" (see below).

pager Program to use for output of pager-piped commands (those beginning with a | character). By default, $ENV{PAGER} will be used.

PrintRet Enables printing of return value after r command.

frame Enables printing messages on entry and exit from subroutines.




The following options affect what happens with V, X, and x commands:

Option Value
arrayDepth hashDepth Print only to depth n (`` for all).

compactDump veryCompact Change style of array and hash dump.

globPrint Whether to print contents of globs.

DumpDBFiles Dump arrays holding debugged files.

DumpPackages Dump symbol tables of packages.

quote HighBit undefPrint Change style of string dump.

tkRunning Run Tk while prompting (with ReadLine).[1]

signalLevel warnLevel dieLevel Level of verbosity.

Footnotes:


[1] A Perl application is usually frozen when sitting at the debugger prompt. Tk support keeps the event loop of Tk running while reading the prompt.




During startup, options are initialized from $ENV{PERLDB_OPTS}. You can put additional initialization options TTY, noTTY, ReadLine, and NonStop there. Here's an example using the $ENV{PERLDB_OPTS} variable:


$ PERLDB_OPTS="N f=2" perl -d myprogram

This will run the script myprogram without human intervention, printing out the call tree with entry and exit points. Note that "N f=2" is equivalent to "NonStop=1 frame=2".


< command

Set an action to happen before every debugger prompt. A multi-line command may be entered by backslashing the newlines. command should be Perl code.


> command

Set an action to happen after the prompt when you've just given a command to return to executing the script. A multi-line command may be entered by backslashing the newlines. command should be Perl code.


! number

Redo a previous command (defaults to previous command).


! -number

Redo number'th-to-last command.


! pattern

Redo last command that started with pattern. See "O recallCommand", too.


!! cmd

Run cmd in a subprocess (which will read from DB::IN, write to DB::OUT). See "O shellBang", too.


H -number

Display last number commands. Only commands longer than one character are listed. If number is omitted, lists them all.


q or ^D

Quit. ("quit" doesn't quite work for this.)


R

Restart the debugger by execing a new session. It tries to maintain your history across this, but internal settings and command line options may be lost.


|dbcmd

Run debugger command, piping DB::OUT to $ENV{PAGER}.


||dbcmd

Same as |dbcmd but DB::OUT is temporarily selected as well. Often used with commands that would otherwise produce long output, such as


|V main



= [alias value]

Define a command alias, or list current aliases.


command

Execute command as a Perl statement. A semicolon is not needed at the end.

Using the Debugger
If you have any compile-time executable statements (code within a BEGIN block or a use statement), they will not be stopped by the debugger, although requires will.

The debugger prompt is something like:


DB<8>

or even:


DB<<17>>

where that number is the command number. A csh-like history mechanism allows you to access previous commands by number. For example, !17 would repeat command number 17. The number of angle brackets indicates the depth of the debugger. You get more than one set of brackets, for example, if you're already at a breakpoint and then print out the result of a function call that itself also has a breakpoint.

If you want to enter a multi-line command, such as a subroutine definition with several statements, you may escape the newline that would normally end the debugger command with a backslash. Here's an example:


DB<1> for (1..4) { \
cont: print "ok\n"; \
cont: }
ok
ok
ok
ok

Note that this business of escaping a newline is specific to interactive commands typed into the debugger.

Let's say you want to fire up the debugger on a little program of yours (let's call it camel_flea), and stop it as soon as it gets down to a function named infested. Here's how you'd do that:


shell_prompt% perl -d camel_flea
Stack dump during die enabled outside of evals.
Loading DB routines from perl5db.pl patch level 0.94
Emacs support available.
Enter h or `h h' for help.
main:camel_flea:3): $a = 1;
DB<1>

The debugger halts your program right before the first run-time executable statement (but see above regarding compile-time statements) and asks you to enter a command. Contrary to popular expectations, whenever the debugger stops to show you a line of code, it displays the line it's about to execute, not the one it just executed.

Now, you'd like to stop as soon as your program gets to the infested function, so you enter a breakpoint there like so:


DB<1> b infested
DB<2> c

The debugger now continues until it hits that function, at which point it does this:


main::infested(camel_flea:12): my bugs;

It might be nice to look at a window of source code around the breakpoint, so you use the w command:


DB<2> w
9: }
10:
11: sub infested {
12==>b my $bugs;
13: return 3.5;
14: }
DB<2>

As you see, your current line is line 12, and it has a breakpoint on it.

Now, you'd like to see who called whom, so you ask for a stack backtrace:


DB<2> T
$ = main::infested called from file `Ambulation.pm' line 10
@ = Ambulation::legs(1, 2, 3, 4) called from file `camel_flea' line 7
$ = main:ests('bactrian', 4) called from file `camel_flea' line 4

The left-hand character up there ($ or @) tells whether the function was called in a scalar or list context (we bet you can tell which is which). There are three lines because you were three functions deep when you ran the stack backtrace. Here's what each line means:


Line number one says you were in the function main::infested when you ran the stack dump. It tells you the function was called in a scalar context from line 10 of the file Ambulation.pm. It also shows that it was called without any arguments whatsoever, meaning it was called as &infested.

Line number two shows that the function Ambulation::legs was called in a list context from the camel_flea file with four arguments.

Line number three shows that main:ests was called in a scalar context, also from camel_flea, but from line 4.

Limited control over the Perl debugger can also be managed from within your Perl script itself. You might do this, for example, to set an automatic breakpoint at a certain subroutine whenever a particular program is run under the debugger. Setting $DB::single to 1 will stop at the next statement as though you'd used the debugger's s command. If you set $DB::single to 2, it's equivalent to having just typed the n command. The $DB::trace variable can be set to 1 to simulate having typed the t command.

Debugger Customization
To modify the debugger, copy perl5db.pl from the Perl library to another file and modify it as necessary. You'll also want to set your PERL5DB environment variable to say something like this:


BEGIN { require "myperl5db.pl" }

You can do some customization by setting up a .perldb file with initialization code. For instance, you could make aliases like these (the last one is one people expect to be there):


$DB::alias{'len'} = 's/^len(.*)/p length($1)/';
$DB::alias{'stop'} = 's/^stop (at|in)/b/';
$DB::alias{'ps'} = 's/^ps\b/p scalar /';
$DB::alias{'quit'} = 's/^quit\b.*/exit/';

Readline Support
As shipped, the only command-line history mechanism supplied is a simplistic one that checks for leading exclamation points. This is fine for casual use. However, if you install the Term::ReadKey and Term::ReadLine modules from CPAN, you will have full editing capabilities much like GNU readline (3) provides. Look for these in the modules/by-module/Term directory on CPAN.

Editor Support for Debugging
If you have GNU emacs installed on your system, it can interact with the Perl debugger to provide an integrated software development environment reminiscent of its interactions with C debuggers.

Perl is also delivered with a start file for making emacs act like a syntax-directed editor that understands (some of) Perl's syntax. Look in the emacs/ directory of the Perl source distribution.

(Historically, a similar setup for interacting with vi and the X11 window system had also been available, but at the time of this writing, no debugger support for vi currently exists.)

Debugger Internals
When you call the caller function from package DB, Perl sets the @DB::args array to the arguments that stack frame was called with. It also maintains other magical internal variables, such as @DB::dbline, an array of the source code lines for the currently selected (with the debugger's f command) file. Perl effectively inserts a call to the function DB:B(linenum) in front of every place that can have a breakpoint. Instead of a subroutine call it calls DB::sub, setting $DB::sub to the name of the called subroutine. It also inserts a BEGIN {require 'perl5db.pl'} before the first line, since no subroutine call is possible until &DB::sub is defined (for subroutines defined outside this file). In fact, the same is true if $DB::deep (how many levels of recursion deep into the debugger you are) is not defined.

At the start, the debugger reads your config file (. /.perldb or ~/.perldb under UNIX), which can set important options. This file may define a subroutine &afterinit to be executed after the debugger is initialized.

After the config file is processed, the debugger consults the environment variable PERLDB_OPTS and parses it as arguments to the O opt=val debugger command.

The following options can only be specified at startup. To set them in your config file, call &parse_options(`opt=val`).


TTY

The TTY to use for debugging I/O.


noTTY

If set, goes in NonStop mode. On an interrupt, if TTY is not set, it uses the value of noTTY or /tmp/perldbtty$$ to find TTY using Term::Rendezvous. The current variant is to have the name of TTY in this file.


ReadLine

If false, a dummy ReadLine is used so that you can debug ReadLine applications.


NonStop

If true, no interaction is performed until an interrupt.


LineInfo

File or pipe to print line number info to. If it's a pipe, then a short, emacs-like message is used. Example config file:


&parse_options("NonStop=1 LineInfo=db.out");
sub afterinit { $trace = 1; }

The script will run without human intervention, putting trace information into the file db.out. (If you interrupt it, you had better reset LineInfo to something "interactive"!)

Debugger Bugs
If your program exits or dies, so too does the debugger.

You cannot get the stack frame information or otherwise debug functions that were not compiled by Perl, such as C or C++ extensions.

If you alter your @_ arguments in a subroutine (such as with shift or pop), the stack backtrace will not show the original values.

Alternative Debuggers: The Perl Profiler
If you wish to supply an alternative debugger for Perl to run, just invoke your script with the -d:module switch. One of the most popular alternative debuggers for Perl is DProf, the Perl profiler. As of this writing, DProf was not included with the standard Perl distribution, but it is expected to be included "real soon now."

Meanwhile, you can fetch the Devel:Prof module from CPAN. Assuming it's properly installed on your system, you can use it to profile the Perl program in mycode.pl by typing:


perl -dProf mycode.pl

When the script terminates, the profiler will dump the profile information to a file called tmon.out. A tool like dprofpp (also supplied with the Devel:Prof package) interprets the profile.

Other Debugging Resources
You did try the -w switch, didn't you?
mic64 目前離線  
送花文章: 0, 收花文章: 21 篇, 收花: 61 次
舊 2004-05-20, 01:13 PM   #9 (permalink)
註冊會員
 
mic64 的頭像
榮譽勳章
UID - 582
在線等級: 級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時
註冊日期: 2002-12-06
VIP期限: 2007-04
住址: MIB總部
文章: 412
精華: 0
現金: 499 金幣
資產: 499 金幣
預設

9. Diagnostic Messages
These messages are classified as follows (listed in increasing order of desperation):

Class Meaning
(W) A warning (optional)
(D) A deprecation (optional)
(S) A severe warning (mandatory)
(F) A fatal error (trappable)
(P) An internal error (panic) that you should never see (trappable)
(X) A very fatal error (non-trappable)
(A) An alien error message (not generated by Perl)



Optional warnings are enabled by using the -w switch. Warnings may be captured by setting $SIG{_ _WARN_ _} to a reference to a routine that will be called on each warning before printing it. Trappable errors may be trapped using eval. You can also capture control before a trappable error "dies" by setting $SIG{_ _DIE_ _} to a subroutine reference, but if you don't call die within that handler, the fatal exception is still thrown when you return from it. In other words, you're not allowed to "de-fatalize" an exception that way. You must use an eval wrapper for that.

In the following messages %s stands for an interpolated string that is determined only when the message is generated. (Similarly, %d stands for an interpolated number--think printf formats, but we use %d to mean a number in any base here.) Note that some messages begin with %s --which means that listing them alphabetically is problematical. You should search among these messages if the one you are looking for does not appear in the expected place. The symbols " % - ? @ sort before alphabetic characters, while [ and \ sort after.

References of the form, "See unpack," refer to entries in Chapter 3, Functions.

If you decide a bug is a Perl bug and not your bug, you should try to reduce it to a minimal test case and then report it with the perlbug program that comes with Perl.


`my` variable %s can't be in a package

(F) Lexically scoped variables aren't in a package, so it doesn't make sense to try to declare one with a package qualifier on the front. Use local if you want to localize a package variable.


`no` not allowed in expression

(F) The no keyword is recognized and executed at compile time, and returns no useful value.


`use` not allowed in expression

(F) The use keyword is recognized and executed at compile time, and returns no useful value.


% may only be used in unpack

(F) You can't pack a string by supplying a checksum, since the checksumming process loses information, and you can't go the other way. See unpack.


%s (...) interpreted as function

(W) You've run afoul of the rule that says that any list operator followed by parentheses turns into a function, with all the list operator's arguments found inside the parens. See the section "Terms and List Operators (Leftward)" in Chapter 2, The Gory Details.


%s argument is not a HASH element

(F) The argument to delete or exists must be a hash element, such as


$foo{$bar}
$ref->[12]->{"susie"}



%s did not return a true value

(F) A required (or used) file must return a true value to indicate that it compiled correctly and ran its initialization code correctly. It's traditional to end such a file with a "1;", though any true value would do. See require.

%s found where operator expected

(S) The Perl lexer knows whether to expect a term or an operator. If it sees what it knows to be a term when it was expecting to see an operator, it gives you this warning. Usually it indicates that an operator or delimiter was omitted, such as a semicolon.


%s had compilation errors.

(F) The final summary message when a perl -c command fails.


%s has too many errors.

(F) The parser has given up trying to parse the program after 10 errors. Further error messages would likely be uninformative.


%s matches null string many times

(W) The pattern you've specified would be an infinite loop if the regular expression engine didn't specifically check for that.


%s never introduced

(S) The symbol in question was declared but somehow went out of scope before it could possibly have been used.


%s syntax OK

(F) The final summary message when a perl -c command succeeds.


%s: Command not found.

(A) You've accidentally run your script through csh instead of perl. Check the #! line, or manually feed your script into perl yourself.


%s: Expression syntax.

(A) You've accidentally run your script through csh instead of perl. Check the #! line, or manually feed your script into perl yourself.


%s: Undefined variable.

(A) You've accidentally run your script through csh instead of perl. Check the #! line, or manually feed your script into perl yourself.


%s: not found

(A) You've accidentally run your script through the Bourne shell instead of perl. Check the #! line, or manually feed your script into perl yourself.


-P not allowed for setuid/setgid script

(F) The script would have to be opened by the C preprocessor by name, which provides a race condition that breaks security.


-T and -B not implemented on filehandles

(F) Perl can't peek at the stdio buffer of filehandles when it doesn't know about your kind of stdio. You'll have to use a filename instead.


500 Server error

See Server error.


?+* follows nothing in regexp

(F) You started a regular expression with a quantifier. Backslash it if you meant it literally.


@ outside of string

(F) You had a pack template that specified an absolute position outside the string being unpacked. See pack.


accept() on closed fd

(W) You tried to do an accept on a closed socket. Did you forget to check the return value of your socket call? See accept.


Allocation too large: %d

(F) You can't allocate more than 64K on an MS-DOS machine.


Arg too short for msgsnd

(F) msgsnd requires a string at least as long as sizeof(long).


Ambiguous use of %s resolved as %s

(W)(S) You said something that may not be interpreted the way you thought. Normally it's pretty easy to disambiguate it by supplying a missing quote, operator, pair of parentheses, or declaration.


Args must match #! line

(F) The setuid emulator requires that the switches perl was invoked with match the switches specified on the #! line.


Argument `%s` isn't numeric

(W) The indicated string was fed as an argument to an operator that expected a numeric value instead. If you're fortunate the message will identify which operator was so unfortunate.


Array @%s missing the @ in argument %d of %s()

(D) Really old Perl let you omit the @ on array names in some spots. This is now heavily deprecated.


assertion botched: %s

(P) The malloc (3) package that comes with Perl had an internal failure.


Assertion failed: file `%s`

(P) A general assertion failed. The file in question must be examined.


Assignment to both a list and a scalar

(F) If you assign to a conditional operator, the second and third arguments must either both be scalars or both be lists. Otherwise Perl won't know which context to supply to the right side.


Attempt to free non-arena SV: %d

(P) All SV objects are supposed to be allocated from arenas that will be garbage collected upon exit. An SV was discovered to be outside any of those arenas. This probably means that someone screwed up in a C extension module.


Attempt to free temp prematurely

(W) Mortalized values are supposed to be freed by the internal free_tmps() routine. This indicates that something else is freeing the SV before the free_tmps() routine gets a chance, which means that the free_tmps() routine will be freeing an unreferenced scalar when it does try to free it.


Attempt to free unreferenced glob pointers

(P) The reference counts got screwed up on symbol aliases.


Attempt to free unreferenced scalar

(W) Perl went to decrement the reference count of a scalar to see if it would go to 0, and discovered that it had already gone to 0 earlier, and should have been freed, and in fact, probably was freed. This could indicate that SvREFCNT_dec() was called too many times, or that SvREFCNT_inc() was called too few times, or that the SV was mortalized when it shouldn't have been, or that memory has been corrupted. In any event, it's likely a problem with the C extension module you're developing.


Bad arg length for %s, is %d, should be %d

(F) You passed a buffer of the wrong size to one of msgctl, semctl or shmctl. In C parlance, the correct sizes are sizeof(struct msqid_ds *), sizeof(struct semid_ds *) and sizeof(struct shmid_ds *), respectively.


Bad associative array

(P) One of the internal hash routines was passed a null HV pointer.


Bad filehandle: %s

(F) A symbol was passed to something wanting a filehandle, but the symbol has no filehandle associated with it. Perhaps you didn't do an open, or did it in another package.


Bad free() ignored

(S) An internal routine called free (3) on something that had never been malloc (3)ed in the first place.


Bad name after %s::

(F) You started to name a symbol by using a package prefix, and then didn't finish the symbol. In particular, you can't interpolate outside of quotes, so


$var = 'myvar';
$sym = mypack::$var;

is not the same as


$var = 'myvar';
$sym = "mypack::$var";



Bad symbol for array

(P) An internal request asked to add an array entry to something that wasn't a symbol table entry.


Bad symbol for filehandle

(P) An internal request asked to add a filehandle entry to something that wasn't a symbol table entry.


Bad symbol for hash

(P) An internal request asked to add a hash entry to something that wasn't a symbol table entry.


Badly placed ()'s

(A) You've accidentally run your script through csh instead of perl. Check the #! line, or manually feed your script into perl yourself.


BEGIN failed- -compilation aborted

(F) An untrapped exception was raised while executing a BEGIN subroutine. Compilation stops immediately and the interpreter is exited.


bind() on closed fd

(W) You tried to do a bind on a closed socket. Did you forget to check the return value of your socket call? See bind.


Bizarre copy of %s in %s

(P) Perl detected an attempt to copy an internal value that is not copiable.


Callback called exit

(F) A subroutine invoked from an external package via perl_call_sv() exited by calling exit.


Can't `last` outside a block

(F) A last statement was executed to break out of the current block, except that there's this itty bitty problem called there isn't a current block. See note on the next entry.


Can't `next` outside a block

(F) A next statement was executed to reiterate the current block, but there isn't a current block. Note that an if or else block doesn't count as a "loopish" block. You can usually double the curly brackets to get the same effect though, since the inner brackets will be considered a block that loops once. See last.


Can't `redo` outside a block

(F) A redo statement was executed to restart the current block, but there isn't a current block. See note on the previous entry.


Can't bless non-reference value

(F) Only hard references may be blessed. This is how Perl "enforces" encapsulation of objects.


Can't break at that line

(S) A debugger warning indicating the line number specified wasn't the location of a statement that could be stopped at.


Can't call method `%s` in empty package `%s`

(F) You called a method correctly, and it correctly indicated a package functioning as a class, but that package doesn't have anything at all defined in it, let alone methods.


Can't call method `%s` on unblessed reference

(F) A method call must know what package it's supposed to run in. It ordinarily finds this out from the object reference you supply, but you didn't supply an object reference in this case. A reference isn't an object reference until it has been blessed.


Can't call method `%s` without a package or object reference

(F) You used the syntax of a method call, but the slot filled by the object reference or package name contains an expression that returns neither an object reference nor a package name. (Perhaps it's null?) Something like this will reproduce the error:


$BADREF = undef;
process $BADREF 1,2,3;
$BADREF->process(1,2,3);



Can't chdir to %s

(F) You called perl -x/foo/bar, but /foo/bar is not a directory that you can chdir (2) to, possibly because it doesn't exist.


Can't coerce %s to integer in %s

(F) Certain types of SVs, in particular real symbol table entries (type GLOB), can't be forced to stop being what they are. So you can't say things like:


*foo += 1; # ERROR

You can say


$foo = *foo; # make a "fake" glob value
$foo += 1;

but then $foo no longer contains a glob.


Can't coerce %s to number in %s

(F) Certain types of SVs, in particular real symbol table entries (type GLOB), can't be forced to stop being what they are. See preceding entry.


Can't coerce %s to string in %s

(F) Certain types of SVs, in particular real symbol table entries (type GLOB), can't be forced to stop being what they are. See previous two entries.


Can't create pipe mailbox

(P) An error peculiar to VMS. The process is suffering from exhausted quotas or other plumbing problems.


Can't declare %s in my

(F) Only scalar, array and hash variables may be declared as lexical variables. They must have ordinary identifiers as names, since lexical variables don't live in a symbol table, and can't be package qualified.


Can't do inplace edit on %s: %s

(S) The creation of the new file failed for the indicated reason.


Can't do inplace edit without backup

(F) You're on a system such as MS-DOS that gets confused if you try reading from a deleted (but still opened) file. You have to use the switch, -i.bak, or some such.


Can't do inplace edit: %s > 14 characters

(S) There isn't enough room in the filename to make a backup name for the file. Perhaps you should get a system with longer filenames. :-)


Can't do inplace edit: %s is not a regular file

(S) You tried to use the -i switch on a special file, such as a file in /dev, or a FIFO. The file was ignored.


Can't do setegid!

(P) The setegid() call failed for some reason in the setuid emulator of suidperl.


Can't do seteuid!

(P) The setuid emulator of suidperl failed for some reason.


Can't do setuid

(F) This typically means that ordinary perl tried to exec suidperl to do setuid emulation, but couldn't exec it. If you're running /usr/local/bin/perl5.003, it looks for a corresponding /usr/local/bin/sperl5.003. (Note the "s".) If the file is there, check the execute permissions. If it isn't, ask your sysadmin why he and/or she removed it.


Can't do waitpid with flags

(F) This machine doesn't have either waitpid (2) or wait4 (2), so only waitpid without flags is emulated.


Can't do {n,m} with n > m

(F) Minima must be less than or equal to maxima. If you really want your regular expression to match something 0 times, just put {0}.


Can't emulate -%s on #! line

(F) The #! line specifies a switch that doesn't make sense at this point. For example, it'd be kind of silly to put a -x on the #! line.


Can't exec `%s`: %s

(W) A system, exec or piped open call could not execute the named program for the indicated reason. Typical reasons include: the permissions were wrong on the file, the file wasn't found in $ENV{PATH}, the executable in question was compiled for another architecture, or the #! line in a script points to an interpreter that can't be run for similar reasons. (Or maybe your system doesn't support #! at all.)


Can't exec %s

(F) Perl was trying to execute the indicated program for you because that's what the #! line said. If that's not what you wanted, you may need to mention "perl" on the #! line somewhere.


Can't execute %s

(F) You used the -S switch, but the script to execute could not be found in the PATH, or at least not with the correct permissions.


Can't find label %s

(F) You said to goto a label that isn't mentioned anywhere that it's possible for us to go to. See goto.


Can't find string terminator %s anywhere before EOF

(F) Perl strings can stretch over multiple lines. This message means that the closing delimiter was omitted. Since bracketed quotes count nesting levels, the following is missing its final parenthesis:


print q(The character '(' starts a s(n)ide comment.)



Can't fork

(F) A fatal error occurred while trying to fork while opening a pipeline.

Can't get filespec - stale stat buffer?

(S) A warning peculiar to VMS. This arises because of the difference between access checks under VMS and under the UNIX model Perl assumes. Under VMS, access checks are done by filename, rather than by bits in the stat buffer, so that ACLs and other protections can be taken into account. Unfortunately, Perl assumes that the stat buffer contains all the necessary information, and passes it, instead of the filespec, to the access-checking routine. It will try to retrieve the filespec using the device name and FID present in the stat buffer, but this works only if you haven't made a subsequent call to the CRTL stat routine, since the device name is overwritten with each call. If this warning appears, the name lookup failed, and the access-checking routine gave up and returned FALSE, just to be conservative. (Note: The access-checking routine knows about the Perl stat operator and file tests, so you shouldn't ever see this warning in response to a Perl command; it arises only if some internal code takes stat buffers lightly.)


Can't get pipe mailbox device name

(P) An error peculiar to VMS. After creating a mailbox to act as a pipe, Perl can't retrieve its name for later use.


Can't get SYSGEN parameter value for MAXBUF

(P) An error peculiar to VMS. Perl asked $GETSYI how big you want your mailbox buffers to be, and didn't get an answer.


Can't goto subroutine outside a subroutine

(F) The deeply magical goto SUBROUTINE call can only replace one subroutine call for another. It can't manufacture one out of whole cloth. In general you should only be calling it out of an AUTOLOAD routine anyway. See goto.


Can't localize a reference

(F) You said something like local $$ref, which is not allowed because the compiler can't determine whether $ref will end up pointing to anything with a symbol table entry, and a symbol table entry is necessary to do a local.


Can't localize lexical variable %s

(F) You used local on a variable name that was previous declared as a lexical variable using my. This is not allowed. If you want to localize a package variable of the same name, qualify it with the package name.

Can't locate %s in @INC

(F) You said to use (or require, or do) a file that couldn't be found in any of the libraries mentioned in @INC. Perhaps you need to set the PERL5LIB environment variable to say where the extra library is, or maybe the script needs to add the library name to @INC with the use lib directive. Or maybe you just misspelled the name of the file. See require.


Can't locate object method `%s` via package `%s`

(F) You called a method correctly, and it correctly indicated a package functioning as a class, but the package doesn't define that method name, nor do any of its base classes (which is why the message says "via" rather than "in").


Can't locate package %s for @%s::ISA

(W) The @ISA array contained the name of another package that doesn't seem to exist.


Can't mktemp()

(F) The mktemp routine failed for some reason while trying to process a -e switch. Maybe your /tmp partition is full, or clobbered.


Can't modify %s in %s

(F) You aren't allowed to assign to the item indicated, or otherwise try to change it, such as with an autoincrement.


Can't modify non-existent substring

(P) The internal routine that does assignment to a substr was handed a NULL pointer.


Can't msgrcv to readonly var

(F) The target of a msgrcv must be modifiable in order to be used as a receive buffer.


Can't open %s: %s

(S) An inplace edit couldn't open the original file for the indicated reason. Usually this is because you don't have read permission for the file.


Can't open bidirectional pipe

(W) You tried to say open(CMD, `|cmd|`), which is not supported. You can try any of several modules in the Perl library to do this, such as Open2. Alternately, direct the pipe's output to a file using ">", and then read it in under a different filehandle.


Can't open error file %s as stderr

(F) An error peculiar to VMS. Perl does its own command-line redirection, and couldn't open for writing the file specified after 2> or 2>> on the command line.


Can't open input file %s as stdin

(F) An error peculiar to VMS. Perl does its own command-line redirection, and couldn't open for reading the file specified after < on the command line.


Can't open output file %s as stdout

(F) An error peculiar to VMS. Perl does its own command-line redirection, and couldn't open for writing the file specified after > or >> on the command line.


Can't open output pipe (name: %s)

(P) An error peculiar to VMS. Perl does its own command-line redirection, and couldn't open the pipe into which to send data destined for STDOUT.


Can't open perl script `%s`: %s

(F) The script you specified can't be opened for the indicated reason.


Can't rename %s to %s: %s, skipping file

(S) The rename done by the -i switch failed for some reason, probably because you don't have write permission to the directory.


Can't reopen input pipe (name: %s) in binary mode

(P) An error peculiar to VMS. Perl thought STDIN was a pipe, and tried to reopen it to accept binary data. Alas, it failed.


Can't reswap uid and euid

(P) The setreuid call failed for some reason in the setuid emulator of suidperl.


Can't return outside a subroutine

(F) The return statement was executed in mainline code, that is, where there was no subroutine call to return out of.


Can't stat script `%s`

(P) For some reason you can't fstat (2) the script even though you have it open already. Bizarre.


Can't swap uid and euid

(P) The setreuid call failed for some reason in the setuid emulator of suidperl.


Can't take log of %d

(F) Logarithms are only defined on positive real numbers.


Can't take sqrt of %d

(F) For ordinary real numbers, you can't take the square root of a negative number. There's a Complex module available for Perl, though, if you really want to do that.


Can't undef active subroutine

(F) You can't undefine a routine that's currently running. You can, however, redefine it while it's running, and you can even undef the redefined subroutine while the old routine is running. Go figure.


Can't unshift

(F) You tried to unshift an "unreal" array that can't be unshifted, such as the main Perl stack.


Can't upgrade that kind of scalar

(P) The internal sv_upgrade( ) routine adds "members" to an SV, making it into a more specialized kind of SV. The top several SV types are so specialized, however, that they cannot be interconverted. This message indicates that such a conversion was attempted.


Can't upgrade to undef

(P) The undefined SV is the bottom of the totem pole, in the scheme of upgradability. Upgrading to undef indicates an error in the code calling sv_upgrade().


Can't use `my %s` in sort comparison

(F) The global variables $a and $b are reserved for sort comparisons. You mentioned $a or $b in the same line as the <=> or cmp operator, and the variable had earlier been declared as a lexical variable. Either qualify the sort variable with the package name, or rename the lexical variable.


Can't use %s for loop variable

(F) Only a simple scalar variable may be used as a loop variable on a foreach.


Can't use %s ref as %s ref

(F) You've mixed up your reference types. You have to dereference a reference of the type needed. You can use the ref function to test the type of the reference, if need be.


Can't use \1 to mean $1 in expression

(W) In an ordinary expression, backslash is a unary operator that creates a reference to its argument. The use of backslash to indicate a backreference to a matched substring is only valid as part of a regular expression pattern. Trying to do this in ordinary Perl code produces a value that prints out looking like SCALAR(0xdecaf). Use the $1 form instead.


Can't use string (`%s`) as %s ref while `strict refs` in use

(F) Only hard references are allowed by use strict refs. Symbolic references are disallowed.


Can't use an undefined value as %s reference

(F) A value used as either a hard reference or a symbolic reference must be a defined value. This helps to de-lurk some insidious errors.


Can't use global %s in `my`

(F) You tried to declare a magical variable as a lexical variable. This is not allowed, because the magic can only be tied to one location (namely the global variable) and it would be incredibly confusing to have variables in your program that looked like magical variables but weren't.


Can't use subscript on %s

(F) The compiler tried to interpret a bracketed expression as a subscript, but to the left of the brackets was an expression that didn't look like an array reference, or anything else subscriptable.


Can't write to temp file for -e: %s

(F) The write (2) routine failed for some reason while trying to process a -e switch. Maybe your /tmp partition is full, or clobbered.


Can't x= to readonly value

(F) You tried to repeat a constant value (perhaps the undefined value) with an assignment operator, which implies modifying the value itself. Perhaps you need to copy the value to a temporary, and repeat that.


Cannot open temporary file

(F) The creat (2) routine failed for some reason while trying to process a -e switch. Maybe your /tmp partition is full, or clobbered.


chmod: mode argument is missing initial 0

(W) A novice will sometimes say


chmod 777, $filename

not realizing that 777 will be interpreted as a decimal number, equivalent to 01411. Octal constants are introduced with a leading 0 in Perl, as in C.


Close on unopened file %s

(W) You tried to close a filehandle that was never opened.


connect() on closed fd

(W) You tried to do a connect on a closed socket. Did you forget to check the return value of your socket call? See connect.


Corrupt malloc ptr %d at %d

(P) The malloc (3) package that comes with Perl had an internal failure.


corrupted regexp pointers

(P) The regular expression engine got confused by what the regular expression compiler gave it.


corrupted regexp program

(P) The regular expression engine got passed a regular expression program without a valid magic number.

Deep recursion on subroutine `%s`

(W) This subroutine has called itself (directly or indirectly) 100 more times than it has returned. This probably indicates an infinite recursion, unless you're writing strange benchmark programs, in which case it indicates something else.


Did you mean &%s instead?

(W) You probably referred to an imported subroutine &FOO as $FOO or some such.


Did you mean $ or @ instead of %?

(W) You probably said %hash{$key} when you meant $hash{$key} or @hash{@keys}. On the other hand, maybe you just meant %hash and got carried away.


Do you need to predeclare %s?

(S) This is an educated guess made in conjunction with the message "%s found where operator expected". It often means a subroutine or module name is being referenced that hasn't been declared yet. This may be because of ordering problems in your file, or because of a missing sub, package, require, or use statement. If you're referencing something that isn't defined yet, you don't actually have to define the subroutine or package before the current location. You can use an empty sub foo; or package FOO; to enter a "forward" declaration.


Don't know how to handle magic of type '%s'

(P) The internal handling of magical variables has been cursed.


do_study: out of memory

(P) This should have been caught by safemalloc() instead.


Duplicate free() ignored

(S) An internal routine has called free() on something that had already been freed.


elseif should be elsif

(S) There is no keyword elseif in Perl because Larry thinks it's ugly. Your code will be interpreted as an attempt to call a method named elseif() for the class returned by the following block. This is unlikely to do what you want.


END failed- -cleanup aborted

(F) An untrapped exception was raised while executing an END subroutine. The interpreter is immediately exited.


Error converting file specification %s

(F) An error peculiar to VMS. Since Perl may have to deal with file specifications in either VMS or UNIX syntax, it converts them to a single form when it must operate on them directly. Either you've passed an invalid file specification to Perl, or you've found a case the conversion routines don't handle. Drat.

Execution of %s aborted due to compilation errors.

(F) The final summary message when a Perl compilation fails.


Exiting eval via %s

(W) You are exiting an eval by unconventional means, such as a goto, or a loop control statement.


Exiting subroutine via %s

(W) You are exiting a subroutine by unconventional means, such as a goto, or a loop control statement.


Exiting substitution via %s

(W) You are exiting a substitution by unconventional means, such as a return, a goto, or a loop control statement.


Fatal VMS error at %s, line %d

(P) An error peculiar to VMS. Something untoward happened in a VMS system service or RTL routine; Perl's exit status should provide more details. The filename in %s and the line number in %d tell you which section of the Perl source code is distressed.


fcntl is not implemented

(F) Your machine apparently doesn't implement fcntl (2). What is this, a PDP-11 or something?


Filehandle %s never opened

(W) An I/O operation was attempted on a filehandle that was never initialized. You need to do an open or a socket call, or call a constructor from the FileHandle package.


Filehandle %s opened only for input

(W) You tried to write on a read-only filehandle. If you intended it to be a read-write filehandle, you needed to open it with +< or +> or +>> instead of with < or nothing. If you only intended to write the file, use > or >>. See open.


Filehandle only opened for input

(W) You tried to write on a read-only filehandle. If you intended it to be a read-write filehandle, you needed to open it with +< or +> or +>> instead of with < or nothing. If you only intended to write the file, use > or >>. See open.


Final $ should be \$ or $name

(F) You must now decide whether the final $ in a string was meant to be a literal dollar sign, or was meant to introduce a variable name that happens to be missing. So you have to add either the backslash or the name.


Final @ should be \@ or @name

(F) You must now decide whether the final @ in a string was meant to be a literal "at" sign, or was meant to introduce a variable name that happens to be missing. So you have to add either the backslash or the name.


Format %s redefined

(W) You redefined a format. To suppress this warning, say


{
local $^W = 0;
eval "format NAME =...";
}



Format not terminated

(F) A format must be terminated by a line with a solitary dot. Perl got to the end of your file without finding such a line. If you think you have such a line, make sure there are no spaces or tabs on either side of the dot.


Found = in conditional, should be ==

(W) You said


if ($foo = 123)

when you meant


if ($foo == 123)

(or something like that).


gdbm store returned %d, errno %d, key `%s`

(S) A warning from the GDBM_File extension module that a store() failed.


gethostent not implemented

(F) Your C library apparently doesn't implement gethostent (3), probably because if it did, it'd feel morally obligated to return every hostname on the Internet. DNS tends to give machines a sense of grandeur.


get{sock,peer}name() on closed fd

(W) You tried to get a socket or peer socket name on a closed socket. Did you forget to check the return value of your socket call?


getpwnam returned invalid UIC %d for user `%s`

(S) A warning peculiar to VMS. The call to sys$getuai underlying the getpwnam function returned an invalid UIC.


Glob not terminated

(F) The lexer saw a left angle bracket in a place where it was expecting a term, so it's looking for the corresponding right angle bracket, and not finding it. Chances are you left out some needed parentheses earlier in the line, and you really meant a "less than".


Global symbol `%s` requires explicit package name

(F) You've said use strict vars, which indicates that all variables must either be lexically scoped (using my), or explicitly qualified to say which package the global variable is in (using :.


goto must have label

(F) Unlike next or last, you're not allowed to goto an unspecified destination, the opinions of Elizabethans nothwithstanding. Go to goto.


Had to create %s unexpectedly

(S) A routine asked for a symbol from a symbol table that ought to have existed already, but for some reason it didn't, and had to be created on an emergency basis to prevent a core dump. This probably indicates a typo in an extension module.


Hash %%s missing the % in argument %d of %s()

(D) Really old Perl let you omit the % on hash names in some spots. This is now heavily deprecated.


Illegal division by zero

(F) You tried to divide a number by 0. Either something was wrong in your logic, or you need to put a conditional in to guard against meaningless input. Maybe both.


Illegal modulus zero

(F) You tried to divide a number by 0 to get the remainder. Most numbers don't take to this kindly.


Illegal octal digit

(F) You used an 8 or 9 in a octal number.


Illegal octal digit ignored

(W) You may have tried to use an 8 or 9 in a octal number. Interpretation of the octal number stopped before the 8 or 9.

Insecure dependency in %s

(F) You tried to do something that the tainting mechanism didn't like. The tainting mechanism is turned on when you're running setuid or setgid, or when you specify -T to turn it on explicitly. The tainting mechanism labels all data that's derived directly or indirectly from the user, who is considered to be unworthy of your trust. If any such data is used in a "dangerous" operation, you get this error.


Insecure directory in %s

(F) You can't use system, exec, or a piped open in a setuid or setgid script if $ENV{PATH} contains a directory that is writable by the world.


Insecure PATH

(F) You can't use system, exec, or a piped open in a setuid or setgid script if $ENV{PATH} is derived from data supplied (or potentially supplied) by the user. The script must set the path to a known value, using trustworthy data.


Internal inconsistency in tracking vforks

(S) A warning peculiar to VMS. Perl keeps track of the number of times you've called fork and exec, in order to determine whether the current call to exec should affect the current script or a subprocess (see exec). Somehow, this count has become scrambled, so Perl is making a guess and treating this exec as a request to terminate the Perl script and execute the specified command.


internal disaster in regexp

(P) Something went badly wrong in the regular expression parser.


internal urp in regexp at /%s/

(P) Something went badly awry in the regular expression parser.


invalid [] range in regexp

(F) The range specified in a character class had a minimum character greater than the maximum character.


ioctl is not implemented

(F) Your machine apparently doesn't implement ioctl (2), which is pretty strange for a machine that supports C.


junk on end of regexp

(P) The regular expression parser is confused.


Label not found for `last %s`

(F) You named a loop to break out of, but you're not currently in a loop of that name, not even if you count where you were called from. See last.


Label not found for `next %s`

(F) You named a loop to continue, but you're not currently in a loop of that name, not even if you count where you were called from. See last.


Label not found for `redo %s`

(F) You named a loop to restart, but you're not currently in a loop of that name, not even if you count where you were called from. See last.


listen() on closed fd

(W) You tried to do a listen on a closed socket. Did you forget to check the return value of your socket call? See listen.


Literal @%s now requires backslash

(F) It used to be that Perl would try to guess whether you wanted an array interpolated or a literal @. It did this when the string was first used at run-time. Now strings are parsed at compile time, and ambiguous instances of @ must be disambiguated, either by putting a backslash to indicate a literal, or by declaring (or using) the array within the program before the string (lexically). (Someday it will simply assume that any unbackslashed @ interpolates an array.)


Method for operation %s not found in package %s during blessing

(F) An attempt was made to specify an entry in an overloading table that somehow doesn't point to a valid method.


Might be a runaway multi-line %s string starting on line %d

(S) This is an advisory indicating that the previously reported error may have been caused by a missing delimiter on a string or pattern, because it eventually ended earlier on the current line.


Misplaced _ in number

(W) An underline in a decimal constant wasn't on a three-digit boundary.


Missing $ on loop variable

(F) Apparently you've been programming in csh too much. Scalar variables are always introduced with a $ in Perl, unlike in the shells, where it can vary from one line to the next.


Missing comma after first argument to %s function

(F) While certain functions allow you to specify a filehandle or an "indirect object" before the argument list, this ain't one of 'em.


Missing operator before %s?

(S) This is an educated guess made in conjunction with the message "%s found where operator expected". Often the missing operator is a comma.


Missing right bracket

(F) The lexer counted more opening curly brackets (braces) than closing ones. Hint: you'll find the missing one near the place you were last editing.


Missing semicolon on previous line?

(S) This is an educated guess made in conjunction with the message "%s found where operator expected". Don't automatically put a semicolon on the previous line just because you saw this message.


Modification of a read-only value attempted

(F) You tried, directly or indirectly, to change the value of a constant. You didn't, of course, try 2 = 1, since the compiler catches that. But an easy way to do the same thing is:


sub mod { $_[0] = 1 }
mod(2);

Another way is to assign to a substr that's off the end of the string.


Modification of non-creatable array value attempted, subscript %d

(F) You tried to make an array value spring into existence, and the subscript was probably negative, even counting from end of the array backwards.


Modification of non-creatable hash value attempted, subscript `%s`

(F) You tried to make a hash value spring into existence, and it couldn't be created for some peculiar reason.


Module name must be constant

(F) Only a bare module name is allowed as the first argument to a use. If you want to get fancier than that, call require within a BEGIN block.


msg%s not implemented

(F) You don't have System V message IPC on your system.


Multidimensional syntax %s not supported

(W) Multidimensional arrays aren't written like $foo[1,2,3]. They're written like $foo[1][2][3], as in C.


Negative length

(F) You tried to do a read/write/send/recv operation with a buffer length that is less than 0. This is difficult to imagine.


nested *?+ in regexp

(F) You can't quantify a quantifier without intervening parens. So things like ** or +* or ?* are illegal, because you can't match things as many times as you want.

Note, however, that the minimal matching quantifiers, *?, +?, and ??, appear to be nested quantifiers, but aren't.


No #! line

(F) The setuid emulator requires that scripts have a well-formed #! line even on machines that don't support the #! construct.


No %s allowed while running setuid

(F) Certain operations are deemed to be too insecure for a setuid or setgid script to even be allowed to attempt. Generally speaking there will be another way to do what you want that is, if not secure, at least securable.


No -e allowed in setuid scripts

(F) A setuid script can't be specified by the user.


No comma allowed after %s

(F) A list operator that has a filehandle or "indirect object" is not allowed to have a comma between that and the following arguments. Otherwise it'd be just another one of the arguments.


No command into which to pipe on command line

(F) An error peculiar to VMS. Perl handles its own command-line redirection, and found a | at the end of the command line, so it doesn't know whither to pipe the output from this command.


No DB:B routine defined

(F) The currently executing code was compiled with the -d switch, but for some reason the perl5db.pl file (or some facsimile thereof) didn't define a routine to be called at the beginning of each statement. Which is odd, because the file should have been required automatically, and should have blown up the require if it didn't parse right.


No dbm on this machine

(P) This is counted as an internal error, because every machine should supply dbm nowadays, since Perl comes with SDBM.


No DBsub routine

(F) The currently executing code was compiled with the -d switch, but for some reason the perl5db.pl file (or some facsimile thereof) didn't define a DB::sub routine to be called at the beginning of each ordinary subroutine call.


No error file after 2> or 2>> on command line

(F) An error peculiar to VMS. Perl handles its own command-line redirection, and found a 2> or a 2>> on the command line, but can't find the name of the file to which to write data destined for STDERR.


No input file after < on command line

(F) An error peculiar to VMS. Perl handles its own command-line redirection, and found a < on the command line, but can't find the name of the file from which to read data for STDIN.


No output file after > on command line

(F) An error peculiar to VMS. Perl handles its own command-line redirection, and found a lone > at the end of the command line, so it doesn't know whither you wanted to redirect STDOUT.


No output file after > or >> on command line

(F) An error peculiar to VMS. Perl handles its own command-line redirection, and found a > or a >> on the command line, but can't find the name of the file to which to write data destined for STDOUT.


No Perl script found in input

(F) You called perl -x, but no line was found in the file beginning with #! and containing the word "perl".


No setregid available

(F) Configure didn't find anything resembling the setregid (2) call for your system.


No setreuid available

(F) Configure didn't find anything resembling the setreuid (2) call for your system.


No space allowed after -I

(F) The argument to -I must follow the -I immediately with no intervening space.


No such pipe open

(P) An error peculiar to VMS. The internal routine my_pclose() tried to close a pipe that hadn't been opened. This should have been caught earlier as an attempt to close an unopened filehandle.


No such signal: SIG%s

(W) You specified a signal name as a subscript to %SIG that was not recognized. Say kill -l in your shell to see the valid signal names on your system.


Not a CODE reference

(F) Perl was trying to evaluate a reference to a code value (that is, a subroutine), but found a reference to something else instead. You can use the ref function to find out what kind of reference it really was.


Not a format reference

(F) I'm not sure how you managed to generate a reference to an anonymous format, but this indicates you did, and that it didn't exist.


Not a GLOB reference

(F) Perl was trying to evaluate a reference to a typeglob (that is, a symbol table entry that looks like *foo), but found a reference to something else instead. You can use the ref function to find out what kind of reference it really was.


Not a HASH reference

(F) Perl was trying to evaluate a reference to a hash value, but found a reference to something else instead. You can use the ref function to find out what kind of reference it really was.


Not a perl script

(F) The setuid emulator requires that scripts have a well-formed #! line even on machines that don't support the #! construct. The line must mention "perl".


Not a SCALAR reference

(F) Perl was trying to evaluate a reference to a scalar value, but found a reference to something else instead. You can use the ref function to find out what kind of reference it really was.


Not a subroutine reference

(F) Perl was trying to evaluate a reference to a code value (that is, a subroutine), but found a reference to something else instead. You can use the ref function to find out what kind of reference it really was.


Not a subroutine reference in %OVERLOAD

(F) An attempt was made to specify an entry in an overloading table that somehow doesn't point to a valid subroutine.


Not an ARRAY reference

(F) Perl was trying to evaluate a reference to an array value, but found a reference to something else instead. You can use the ref function to find out what kind of reference it really was.


Not enough arguments for %s

(F) The function requires more arguments than you specified.


Not enough format arguments

(W) A format specified more picture fields than the subsequent values line supplied.


Null filename used

(F) You can't require the null filename, especially since on many machines that means the current directory! See require.


NULL OP IN RUN

(P) Some internal routine called run() with a null opcode pointer.


Null realloc

(P) An attempt was made to realloc (3) NULL.


NULL regexp argument

(P) The internal pattern-matching routines blew it bigtime.


NULL regexp parameter

(P) The internal pattern-matching routines are out of their gourd.


Odd number of elements in hash list

(S) You specified an odd number of elements to a hash list, which is odd, since hash lists come in key/value pairs.


oops: oopsAV

(S) An internal warning that the grammar is screwed up.


oops: oopsHV

(S) An internal warning that the grammar is screwed up.


Operation `%s' %s: no method found

(F) An attempt was made to use an entry in an overloading table that somehow no longer points to a valid method.


Operator or semicolon missing before %s

(S) You used a variable or subroutine call where the parser was expecting an operator. The parser has assumed you really meant to use an operator, but this is highly unlikely to be correct. For example, if you say *foo *foo it will be interpreted as if you said *foo * 'foo'.


Out of memory for yacc stack

(F) The byacc parser wanted to grow its stack so it could continue parsing, but realloc (3) wouldn't give it more memory, virtual or otherwise.


Out of memory!

(X) malloc (3) returned 0, indicating there was insufficient remaining memory (or virtual memory) to satisfy the request.


page overflow

(W) A single call to write produced more lines than can fit on a page.


panic: ck_grep

(P) Failed an internal consistency check trying to compile a grep.


panic: ck_split

(P) Failed an internal consistency check trying to compile a split.


panic: corrupt saved stack index

(P) The savestack was requested to restore more localized values than there are in the savestack.


panic: die %s

(P) We popped the context stack to an eval context, and then discovered it wasn't an eval context.


panic: do_match

(P) The internal pp_match() routine was called with invalid operational data.


panic: do_split

(P) Something terrible went wrong in setting up for the split.


panic: do_subst

(P) The internal pp_subst() routine was called with invalid operational data.


panic: do_trans

(P) The internal do_trans() routine was called with invalid operational data.


panic: goto

(P) We popped the context stack to a context with the specified label, and then discovered it wasn't a context we know how to do a goto in.


panic: INTERPCASEMOD

(P) The lexer got into a bad state at a character case modifier like \u.


panic: INTERPCONCAT

(P) The lexer got into a bad state parsing a string with brackets.


panic: last

(P) We popped the context stack to a block context, and then discovered it wasn't a block context.


panic: leave_scope clearsv

(P) A writable lexical variable became read-only somehow within the scope.


panic: leave_scope inconsistency

(P) The savestack probably got out of sync. At any rate, there was an invalid enum on the top of it.


panic: malloc

(P) Something requested a negative number of bytes of malloc (3).


panic: mapstart

(P) The compiler is screwed up with respect to the map function.


panic: null array

(P) One of the internal array routines was passed a null AV pointer.


panic: pad_alloc

(P) The compiler got confused about which scratchpad it was allocating and freeing temporaries and lexicals from.


panic: pad_free curpad

(P) The compiler got confused about which scratchpad it was allocating and freeing temporaries and lexicals from.


panic: pad_free po

(P) An invalid scratchpad offset was detected internally.


panic: pad_reset curpad

(P) The compiler got confused about which scratchpad it was allocating and freeing temporaries and lexicals from.


panic: pad_sv po

(P) An invalid scratchpad offset was detected internally.


panic: pad_swipe curpad

(P) The compiler got confused about which scratchpad it was allocating and freeing temporaries and lexicals from.


panic: pad_swipe po

(P) An invalid scratchpad offset was detected internally.


panic: pp_iter

(P) The foreach iterator got called in a non-loop context frame.


panic: realloc

(P) Something requested a negative number of bytes of realloc (3).


panic: restartop

(P) Some internal routine requested a goto (or something like it), and didn't supply the destination.


panic: return

(P) We popped the context stack to a subroutine or eval context, and then discovered it wasn't a subroutine or eval context.


panic: scan_num

(P) scan_num() got called on something that wasn't a number.


panic: sv_insert

(P) The sv_insert() routine was told to remove more string than there was string.


panic: top_env

(P) The compiler attempted to do a goto, or something weird like that.


panic: yylex

(P) The lexer got into a bad state while processing a character case modifier like \u.


Parens missing around `%s` list

(W) You said something like


my $foo, $bar = @_;

when you meant


my ($foo, $bar) = @_;

Remember that my and local bind closer than comma.


Perl %s required- -this is only version %s, stopped

(F) The module in question uses features of a version of Perl more recent than the currently running version. How long has it been since you upgraded, anyway? See require.


Permission denied

(F) The setuid emulator in suidperl decided you were up to no good.


pid %d not a child

(W) A warning peculiar to VMS. waitpid was asked to wait for a process which isn't a subprocess of the current process. While this is fine from VMS's perspective, it's probably not what you intended.


POSIX getpgrp can't take an argument

(F) Your C compiler uses POSIX getpgrp (2), which takes no argument, unlike the BSD version, which takes a pid.


Possible memory corruption: %s overflowed 3rd argument

(F) An ioctl (2) or fcntl (2) returned more than Perl was bargaining for. Perl guesses a reasonable buffer size, but puts a sentinel byte at the end of the buffer just in case. This sentinel byte got clobbered, and Perl assumes that memory is now corrupted. You can try to trap this with eval, but remember your malloc arena may have been clobbered. Expect your program to dump core soon. If you're lucky, it won't set fire to the laser printer first. See ioctl.


Precedence problem: open %s should be open(%s)

(S) The old irregular construct


open FOO || die;

is now misinterpreted as


open(FOO || die);

because of the strict regularization of Perl 5's grammar into unary and list operators. (The old open was a little of both.) You must put parens around the filehandle, or use the new or operator instead of ||.


print on closed filehandle %s

(W) The filehandle you're printing on got itself closed sometime before now. Check your logic flow. It may have flowed away.


printf on closed filehandle %s

(W) The filehandle you're writing to got itself closed sometime before now. Check your logic flow. See previous joke.


Probable precedence problem on %s

(W) The compiler found a bare word where it expected a conditional, which often indicates that an || or && was parsed as part of the last argument of the previous construct, for example:


open FOO || die;



Prototype mismatch: (%s) vs (%s)

(S) The subroutine being defined had a predeclared (forward) declaration with a different function prototype. The prototypes must match.


Read on closed filehandle <%s>

(W) The filehandle you're reading from got itself closed sometime before now. Check your logic flow. Don't see the previous joke.


Reallocation too large: %d

(F) You can't allocate more than 64K on an MS-DOS machine.


Recompile perl with -DDEBUGGING to use -D switch

(F) You can't use the -D option unless the code to produce the desired output is compiled into perl, which entails some overhead, which is why it's currently left out of your copy.


Recursive inheritance detected

(F) More than 100 levels of inheritance were used. Probably indicates an unintended loop in your inheritance hierarchy. Use -Do to trace object method lookups. (But see previous entry.)


Reference miscount in sv_replace()

(W) The internal sv_replace() function was handed a new SV with a reference count of other than 1.


regexp memory corruption

(P) The regular expression engine got confused by what the regular expression compiler gave it.


regexp out of space

(P) A "can't happen" error, because safemalloc() should have caught it earlier. If it didn't, your Perl is misconfigured.


regexp too big

(F) The current implementation of regular expression uses 16-bit shorts as address offsets within a string. Unfortunately this means that if the regular expression compiles to longer than 32767 bytes, it'll blow up. Usually when you want a regular expression this big, there is a better way to do it with multiple statements.


Reversed %s= operator

(W) You wrote your assignment operator backward. The = must always come last, to avoid ambiguity with subsequent unary operators.


Runaway format

(F) Your format contained the ~~ repeat-until-blank sequence, but it produced 200 lines at once, and the 200th line looked exactly like the 199th line. Apparently you didn't arrange for the arguments to exhaust themselves, either by using ^ instead of @ (for scalar variables), or by shifting or popping (for array variables).


Scalar value @%s[%s] better written as $%s[%s]

(W) You've used an array slice (indicated by @) to select a single value of an array. Generally it's better to ask for a scalar value (indicated by $). The difference is that $foo[&bar] always behaves like a scalar, both when assigning to it and when evaluating its argument, while @foo[&bar] behaves like a list when you assign to it, and provides a list context to its subscript, which can do weird things if you're only expecting one subscript. On the other hand, if you were actually hoping to treat the array element as a list, you need to look into how references work, since Perl will not magically convert between scalars and lists for you.


Script is not setuid/setgid in suidperl

(F) Oddly, the suidperl program was invoked on a script with its setuid or setgid bit unset. This doesn't make much sense.


Search pattern not terminated

(F) The lexer couldn't find the final delimiter of a // or m{} construct. Remember that bracketing delimiters count nesting level.


seek() on unopened file

(W) You tried to use the seek function on a filehandle that was either never opened or has been closed since.


select not implemented

(F) This machine doesn't implement the select (2) system call.


sem%s not implemented

(F) You don't have System V semaphore IPC on your system.


semi-panic: attempt to dup freed string

(S) The internal newSVsv() routine was called to duplicate a scalar that had previously been marked as free.


Semicolon seems to be missing

(W) A nearby syntax error was probably caused by a missing semicolon, or possibly some other missing operator, such as a comma.


Send on closed socket

(W) The filehandle you're sending to got itself closed sometime before now. Check your logic flow.


Sequence (?#... not terminated

(F) A regular expression comment must be terminated by a closing parenthesis. Embedded parentheses aren't allowed. But with the /x modifier you can use an ordinary comment starting with #, which doesn't care.


Sequence (?%s...) not implemented

(F) A proposed regular expression extension has the character reserved but has not yet been written.


Sequence (?%s...) not recognized

(F) You used a regular expression extension that doesn't make sense.


Server error

(A) Also known as "500 Server error". This is a CGI error, not a Perl error. You need to make sure your script is executable, is accessible by the user CGI is running the script under (which is probably not the user account you tested it under), does not rely on any environment variables (like PATH) from the user it isn't running under, and isn't in a location where the CGI server can't find it, basically, more or less.


setegid() not implemented

(F) You tried to assign to $), and your operating system doesn't support the setegid (2) system call (or equivalent), or at least Configure didn't think so.


seteuid() not implemented

(F) You tried to assign to $>, and your operating system doesn't support the seteuid (2) system call (or equivalent), or at least Configure didn't think so.


setrgid() not implemented

(F) You tried to assign to $(, and your operating system doesn't support the setrgid (2) system call (or equivalent), or at least Configure didn't think so.


setruid() not implemented

(F) You tried to assign to $<, and your operating system doesn't support the setruid (2) system call (or equivalent), or at least Configure didn't think so.


Setuid/gid script is writable by world

(F) The setuid emulator won't run a script that is writable by the world, because the world might have written on it already.


shm%s not implemented

(F) You don't have System V shared memory IPC on your system.


shutdown() on closed fd

(W) You tried to do a shutdown on a closed socket. Seems a bit superfluous.


SIG%s handler `%s` not defined.

(W) The signal handler named in %SIG doesn't, in fact, exist. Perhaps you put it into the wrong package?


sort is now a reserved word

(F) An ancient error message that almost nobody ever runs into anymore. But before sort was a keyword, people sometimes used it as a filehandle.


Sort subroutine didn't return a numeric value

(F) A sort comparison routine must return a number. You probably blew it by not using <=> or cmp, or by not using them correctly. See sort.


Sort subroutine didn't return single value

(F) A sort comparison subroutine may not return a list value with more or less than one element. See sort.


Split loop

(P) The split was looping infinitely. (Obviously, a split shouldn't iterate more times than there are characters of input, which is what happened.) See split.


Stat on unopened file %s

(W) You tried to use the stat function (or an equivalent file test) on a filehandle that was either never opened or has been closed since.


Statement unlikely to be reached

(W) You did an exec with some statement after it other than a die. This is almost always an error, because exec never returns unless there was a failure. You probably wanted to use system instead, which does return. To suppress this warning, put the exec in a block by itself. Or put a die after it.


Subroutine %s redefined

(W) You redefined a subroutine. To suppress this warning, say


{
local $^W = 0;
eval "sub name { ... }";
}



Substitution loop

(P) The substitution was looping infinitely. (Obviously, a substitution shouldn't iterate more times than there are characters of input, which is what happened.) See the discussion of substitution in the section "Pattern-Matching Operators" in Chapter 2, The Gory Details.


Substitution pattern not terminated

(F) The lexer couldn't find the interior delimiter of an s/// or s{}{} construct. Remember that bracketing delimiters count nesting level.


Substitution replacement not terminated

(F) The lexer couldn't find the final delimiter of an s/// or s{}{} construct. Remember that bracketing delimiters count nesting level.


substr outside of string

(W) You tried to reference a substr that pointed outside of a string. That is, the absolute value of the offset was larger than the length of the string. See substr.


suidperl is no longer needed since...

(F) Your perl was compiled with -DSETUID_SCRIPTS_ARE_SECURE_NOW, but a version of the setuid emulator somehow got run anyway.

syntax error

(F) Probably means you had a syntax error. Common reasons include:


A keyword is misspelled.

A semicolon is missing.

A comma is missing.

An opening or closing parenthesis is missing.

An opening or closing brace is missing.

A closing quote is missing.

Often there will be another error message associated with the syntax error giving more information. (Sometimes it helps to turn on -w.) The error message itself often tells you where it was in the line when it decided to give up. Sometimes the actual error is several tokens before this, since Perl is good at understanding random input. Occasionally the line number may be misleading, and once in a blue moon the only way to figure out what's triggering the error is to call perl -c repeatedly, chopping away half the program each time to see if the error went away. Sort of the cybernetic version of 20 Questions.


syntax error at line %d: `%s' unexpected

(A) You've accidentally run your script through the Bourne shell instead of perl. Check the #! line, or manually feed your script into perl yourself.


System V IPC is not implemented on this machine

(F) You tried to do something with a function beginning with sem, shm or msg. See semctl, for example.


Syswrite on closed filehandle

(W) The filehandle you're writing to got itself closed sometime before now. Check your logic flow. If you're tired of that, check someone else's.


tell() on unopened file

(W) You tried to use the tell function on a filehandle that was either never opened or has been closed since.


Test on unopened file %s

(W) You tried to invoke a file test operator on a filehandle that isn't open. Check your logic.


That use of $[ is unsupported

(F) Assignment to $[ is now strictly circumscribed, and interpreted as a compiler directive. You may only say one of


$[ = 0;
$[ = 1;
...
local $[ = 0;
local $[ = 1;
...

This is to prevent the problem of one module changing the array base out from under another module inadvertently. See the section on $[ in Chapter 2, The Gory Details.


The %s function is unimplemented

(F) The function indicated isn't implemented on this architecture, according to the probings of Configure.


The crypt() function is unimplemented due to excessive paranoia.

(F) Configure couldn't find the crypt (3) function on your machine, probably because your vendor didn't supply it, probably because they think the U.S. government thinks it's a secret, or at least that they will continue to pretend that it is. And if you quote me on that, I will deny it.


The stat preceding -l _ wasn't an lstat

(F) It makes no sense to test the current stat buffer for symbolic linkhood if the last stat that wrote to the stat buffer already went past the symlink to get to the real file. Use an actual filename instead.


times not implemented

(F) Your version of the C library apparently doesn't do times (3). I suspect you're not running on UNIX.


Too few args to syscall

(F) There has to be at least one argument to syscall to specify the system call to call, silly dilly.


Too many ('s



Too many )'s

(A) You've accidentally run your script through csh instead of perl. Check the #! line, or manually feed your script into perl yourself.


Too many args to syscall

(F) Perl supports a maximum of 14 args to syscall.


Too many arguments for %s

(F) The function requires fewer arguments than you specified.


trailing \ in regexp

(F) The regular expression ends with an unbackslashed backslash. Backslash it.


Translation pattern not terminated

(F) The lexer couldn't find the interior delimiter of a tr/// or tr[][] construct.

Translation replacement not terminated

(F) The lexer couldn't find the final delimiter of a tr/// or tr[][] construct.


truncate not implemented

(F) Your machine doesn't implement a file truncation mechanism that Configure knows about.


Type of arg %d to %s must be %s (not %s)

(F) This function requires the argument in that position to be of a certain type. Arrays must be @NAME or @{EXPR}. Hashes must be %NAME or %{EXPR}. No implicit dereferencing is allowed--use the {EXPR} forms as an explicit dereference.


umask: argument is missing initial 0

(W) A umask of 222 is incorrect. It should be 0222, since octal literals always start with 0 in Perl, as in C.


Unable to create sub named `%s`

(F) You attempted to create or access a subroutine with an illegal name.


Unbalanced context: %d more PUSHes than POPs

(W) The exit code detected an internal inconsistency in how many execution contexts were entered and left.


Unbalanced saves: %d more saves than restores

(W) The exit code detected an internal inconsistency in how many values were temporarily localized.


Unbalanced scopes: %d more ENTERs than LEAVEs

(W) The exit code detected an internal inconsistency in how many blocks were entered and left.


Unbalanced tmps: %d more allocs than frees

(W) The exit code detected an internal inconsistency in how many mortal scalars were allocated and freed.


Undefined format `%s` called

(F) The format indicated doesn't seem to exist. Perhaps it's really in another package?


Undefined sort subroutine `%s` called

(F) The sort comparison routine specified doesn't seem to exist. Perhaps it's in a different package? See sort.


Undefined subroutine &%s called

(F) The subroutine indicated hasn't been defined, or if it was, it has since been undefined.


Undefined subroutine called

(F) The anonymous subroutine you're trying to call hasn't been defined, or if it was, it has since been undefined.


Undefined subroutine in sort

(F) The sort comparison routine specified is declared but doesn't seem to have been defined yet. See sort.


Undefined top format `%s` called

(F) The format indicated doesn't seem to exist. Perhaps it's really in another package?


unexec of %s into %s failed!

(F) The unexec() routine failed for some reason. See your local FSF representative, who probably put it there in the first place.


Unknown BYTEORDER

(F) There are no byteswapping functions for a machine with this byte order.


unmatched () in regexp

(F) Unbackslashed parentheses must always be balanced in regular expressions. If you're a vi user, the % key is valuable for finding the matching parenthesis.


Unmatched right bracket

(F) The lexer counted more closing curly brackets (braces) than opening ones, so you're probably missing an opening bracket. As a general rule, you'll find the missing one (so to speak) near the place you were last editing.


unmatched [] in regexp

(F) The brackets around a character class must match. If you wish to include a closing bracket in a character class, backslash it or put it first.


Unquoted string `%s` may clash with future reserved word

(W) You used a bareword that might someday be claimed as a reserved word. It's best to put such a word in quotes, or capitalize it somehow, or insert an underbar into it. You might also declare it as a subroutine.


Unrecognized character \%d ignored

(S) A garbage character was found in the input, and ignored, in case it's a weird control character on an EBCDIC machine, or some such.


Unrecognized signal name `%s`

(F) You specified a signal name to the kill function that was not recognized. Say kill -l in your shell to see the valid signal names on your system.


Unrecognized switch: -%s

(F) You specified an illegal option to perl. Don't do that. (If you think you didn't do that, check the #! line to see if it's supplying the bad switch on your behalf.)


Unsuccessful %s on filename containing newline

(W) A file operation was attempted on a filename, and that operation failed, probably because the filename contained a newline, probably because you forgot to chop or chomp it off. See chop.


Unsupported directory function `%s` called

(F) Your machine doesn't support opendir (3) and readdir (3).


Unsupported function %s

(F) This machine doesn't implement the indicated function, apparently. At least, Configure doesn't think so.


Unsupported socket function `%s` called

(F) Your machine doesn't support the Berkeley socket mechanism, or at least that's what Configure thought.


Unterminated <> operator

(F) The lexer saw a left angle bracket in a place where it was expecting a term, so it's looking for the corresponding right angle bracket, and not finding it. Chances are you left out some needed parentheses earlier in the line, and you really meant a "less than".


Use of $# is deprecated

(D) This was an ill-advised attempt to emulate a poorly defined awk feature. Use an explicit printf or sprintf instead.


Use of $* is deprecated

(D) This variable magically turned on multiline pattern matching, both for you and for any luckless subroutine that you happen to call. You should use the new /m and /s modifiers now to do that without the dangerous action-at-a-distance effects of $*.


Use of %s in printf format not supported

(F) You attempted to use a feature of printf that is accessible only from C. This usually means there's a better way to do it in Perl.


Use of %s is deprecated

(D) The construct indicated is no longer recommended for use, generally because there's a better way to do it, and also because the old way has bad side effects.


Use of bare << to mean <<`` is deprecated

(D) You are now encouraged to use the explicitly quoted form if you wish to use a blank line as the terminator of the here-document.


Use of implicit split to @_ is deprecated

(D) It makes a lot of work for the compiler when you clobber a subroutine's argument list, so it's better if you assign the results of a split explicitly to an array (or list).


Use of uninitialized value

(W) An undefined value was used as if it were already defined. It was interpreted as a "" or a 0, but maybe it was a mistake. To suppress this warning, assign an initial value to your variables.


Useless use of %s in void context

(W) You did something without a side effect in a context that does nothing with the return value, such as a statement that doesn't return a value from a block, or the left side of a scalar comma operator. Very often this points not to stupidity on your part, but a failure of Perl to parse your program the way you thought it would. For example, you'd get this if you mixed up your C precedence with Python precedence and said


$one, $two = 1, 2;

when you meant to say


($one, $two) = (1, 2);

Another common error is to use ordinary parentheses to construct a list reference when you should be using square or curly brackets, for example, if you say


$array = (1,2);

when you should have said


$array = [1,2];

The square brackets explicitly turn a list value into a scalar value, while parentheses do not. So when a parenthesized list is evaluated in a scalar context, the comma is treated like C's comma operator, which throws away the left argument, which is not what you want.

Variable `%s` is not exported

(F) While use strict in effect, you referred to a global variable that you thought was imported from another module, because something else of the same name (usually a subroutine) is exported by that module. It usually means you put the wrong funny character on the front of your variable.


Variable name `%s::%s` used only once: possible typo

(W) Typographical errors often show up as unique names. If you had a good reason for having a unique name, then just mention it again somehow to suppress the message. You might consider declaring the variable with use vars.


Variable syntax.

(A) You've accidentally run your script through csh instead of perl. Check the #! line, or manually feed your script into perl yourself.


Warning: unable to close filehandle %s properly.

(S) The implicit close done by an open got an error indication on the close. This usually indicates your filesystem ran out of disk space.


Warning: Use of `%s` without parens is ambiguous

(S) You wrote a unary operator followed by something that looks like a binary operator that could also have been interpreted as a term or unary operator. For instance, if you know that the rand function has a default argument of 1.0, and you write


rand + 5;

you may think you wrote the same thing as


rand() + 5;

but in actual fact, you got


rand(+5);

So put in parentheses to say what you really mean.


Write on closed filehandle

(W) The filehandle you're writing to got itself closed sometime before now. Check your logic flow.


X outside of string

(F) You had a pack template that specified a relative position before the beginning of the string being unpacked. See pack.


x outside of string

(F) You had a pack template that specified a relative position after the end of the string being unpacked. See pack.


Xsub `%s` called in sort

(F) The use of an external subroutine as a sort comparison is not yet supported.

Xsub called in sort

(F) The use of an external subroutine as a sort comparison is not yet supported.


You can't use -l on a filehandle

(F) A filehandle represents an opened file, and when you opened the file it already went past any symlink you are presumably trying to look for. Use a filename instead.


YOU HAVEN'T DISABLED SET-ID SCRIPTS IN THE KERNEL YET!

(F) And you probably never will, since you probably don't have the sources to your kernel, and your vendor probably doesn't give a rip about what you want. Your best bet is to use the wrapsuid script in the eg/ directory to put a setuid C wrapper around your script.


You need to quote `%s`

(W) You assigned a bareword as a signal handler name. Unfortunately, you already have a subroutine of that name declared, which means that Perl 5 will try to call the subroutine when the assignment is executed, which is probably not what you want. (If it IS what you want, put an & in front.)


[gs]etsockopt() on closed fd

(W) You tried to get or set a socket option on a closed socket. Did you forget to check the return value of your socket call? See getsockopt.


\1 better written as $1

(W) Outside of patterns, backreferences live on as variables. The use of backslashes is grandfathered on the righthand side of a substitution, but stylistically it's better to use the variable form because other Perl programmers will expect it, and it works better if there are more than nine backreferences.


'|' and '<' may not both be specified on command line

(F) An error peculiar to VMS. Perl does its own command-line redirection, and found that STDIN was a pipe, and that you also tried to redirect STDIN using <. Only one STDIN stream to a customer, please.


'|' and '>' may not both be specified on command line

(F) An error peculiar to VMS. Perl does its own command-line redirection, and thinks you tried to redirect STDOUT both to a file and into a pipe to another command. You need to choose one or the other, though nothing's stopping you from piping into a program or Perl script which "splits" output into two streams, such as


open(OUT,">$ARGV[0]") or die "Can't write to $ARGV[0]: $!";
while (<STDIN>) {
print STDOUT;
print OUT;
}
close OUT;
mic64 目前離線  
送花文章: 0, 收花文章: 21 篇, 收花: 61 次
舊 2004-05-20, 01:15 PM   #10 (permalink)
註冊會員
 
mic64 的頭像
榮譽勳章
UID - 582
在線等級: 級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時級別:16 | 在線時長:330小時 | 升級還需:27小時
註冊日期: 2002-12-06
VIP期限: 2007-04
住址: MIB總部
文章: 412
精華: 0
現金: 499 金幣
資產: 499 金幣
預設

Glossary
actual arguments
The scalar values that you supply to a function or subroutine when you call it. For instance, when you call piglatin(`bingo`), the string "bingo" is the actual argument. See also argument [1] and formal arguments.

[1] When we italicize a word or phrase in here, it usually means you can find it defined elsewhere in the Glossary. Think of them as hyperlinks.


address operator
A language construct for manipulating the actual location of an object in your computer's memory. Strictly speaking, there are no such operators in Perl, since it handles all that for you automatically. You tell Perl that you want a new thingy, and Perl worries about creating, moving, and destroying the thingy for you. Not so strictly speaking, the backslash operator returns a reference to a thingy, which works much like an address. See also network address.


alternatives
A list of possible choices from which you may select only one, as in "Would you like door A, B, or C?" Alternatives in regular expressions are separated with a vertical bar: |. Alternatives in normal Perl expressions are separated with a double vertical bar: ||. You might say there are two alternatives for alternatives. (Then again, you might not. Your choice.)


anonymous
Used to describe a thingy that is not directly accessible through a named variable. Such a thingy must be indirectly accessible through at least one hard reference. When the last hard reference goes away, the anonymous thingy is destroyed without pity.


architecture
The kind of computer you're working on, where one "kind" of computer means all those computers that can run the same binary program. Since Perl scripts are text files, not binaries, a Perl script is much less sensitive to the architecture it's running on than programs in other languages (such as C) that are compiled into machine code. See also operating system.


argument
A piece of data supplied as input to a program, subroutine, or function when it is invoked to tell it what it's supposed to do. Also called a "parameter".


ARGV
The name of the array containing the argument "vector" from the command line. If you use the empty <> operator, ARGV is both the name of the filehandle used to traverse the arguments, and of the scalar containing the name of the current input file. It's also what you say to your dentist when the Novocaine isn't working.


arithmetic operator
A symbol such as + or ** that tells Perl to do arithmetic. In addition, see operator.


array
A named list of values, each of which has a unique key to identify it. In a normal array, the key is numeric (an integer, in fact). In a hash (an associative array), the key is a string.


array context
A quaint, archaic expression used by people who have read the first edition of this book. Nowadays called list context.


array literal
Strictly, a comma-separated, parenthesized LIST of scalar literals. Used loosely to refer to any parenthesized LIST even if it contains variables or expressions.


array value
Another archaic phrase. See list value.


array variable
A named list that may be processed by functions such as shift and splice that require an array name as the first argument.


ASCII
Used roughly to mean the American Standard Code for Information Interchange (a 7-bit character set), and any international extensions based on it.


assignment
An operation whose mission in life is to change the value of a variable.


assignment operator
A compound operator composed of an ordinary assignment together with some other operator, that changes the value of a variable in place, that is, relative to its old value. For example, $a += 2 adds 2 to $a.


associative array
See hash.


associativity
Determines whether you do the left operator first or the right operator first, when you have "A operator B operator C", if the two operators are of the same precedence. Operators like + are left associative, while operators like ** are right associative. See the section "Operators" in Chapter 2, The Gory Details, for a list of associativity.


autoincrement
To add one to something automatically. Usually used to describe the ++ operator.


autosplit
To split a string automatically on whitespace, such as the -a switch does in order to emulate awk.


AV
Short for "array value", which refers to one of Perl's internal data types. (Not to be confused with array value, by which people usually mean list value.) An AV is a kind of SV.


awk
Descriptive editing term--short for "awkward". Also coincidentally refers to a venerable text processing language from which Perl derived some of its ideas.


backtracking
The practice of saying, "If I had to do it all over, I'd do it differently," and then actually going back and doing it all over differently. Mathematically speaking, it's returning from an unsuccessful recursion on a tree of possibilities. Backtracking happens in Perl when it attempts to match patterns with a regular expression, and its earlier guesses don't pan out.


base class
A generic object class from which other more specific classes are derived genetically by inheritance. Also called a "superclass" by people who respect their ancestors.


BASIC/PLUS
Another ancient language, from which Perl derived exactly one idea. OK, maybe two.[2]

[2] BASIC/PLUS is a registered trademark of Digital Equipment Corporation. And the answers are: statement modifiers and maybe formats.


big-endian
From Swift: someone who eats boiled eggs big end first. Also used of computers that store the most significant byte of a word at a lower byte address than the least significant byte. Often considered superior to little-endian machines. See also little-endian.


binary
Having to do with numbers represented in base two. That means there are basically two numbers, zero and one. Some people think in binary, as shown by the kinds of questions they ask: "Should we all use Perl or Java?" Also used to describe a non-text file, presumably because such a file makes full use of all the binary bits in its bytes.


bit
A very small piece of litter. Also a number in the range zero to one, inclusive.


bit shift
The movement of bits left or right in a computer word, which has the effect of multiplying or dividing by a power of two.


bless
In corporate life, to grant official approval to a thing, as in, "The VP of Engineering has blessed our WebCruncher project." Similarly in Perl, to grant official approval to a thingy so that it can function as a WebCruncher object. See the bless function in Chapter 3, Functions.


block
What a process does when it has to wait for something: "My process blocked waiting for the disk." As an unrelated noun, it refers to a large chunk of data, of a size that the operating system likes to deal with (normally a power of two such as 512 or 8192). Typically refers to a chunk of data that's coming from or going to a disk file.


BLOCK
A syntactic construct consisting of a sequence of Perl statements bounded by braces. The if and while statements are defined in terms of BLOCKs. Sometimes we also say "block" to mean a sequence of statements that act like a BLOCK, such as within an eval or a file, even though the statements aren't bounded by braces.


block buffering
A method of making input and output efficient by doing it a block at a time. By default, Perl does block buffering to disk files. See buffer and command buffering.


Boolean context
A special kind of scalar context in which the program is expecting to decide whether the scalar value returned by an expression is true or false. See context.


breakpoint
A spot in your program where you've told the debugger to stop execution so you can poke around and see whether anything is wrong yet.


BSD
A psychoactive drug, popular in the 80s, probably developed at U. C. Berkeley or thereabouts. Similar in many ways to the prescription-only medication called "System V", but infinitely more useful. (Or, at least, more fun.) The full chemical name is "Berkeley Standard Distribution".


buffer
A temporary holding location for data. Block buffering means that the data is passed on to its destination whenever the buffer is full. Line buffering means that it's passed on whenever a complete line is received. Command buffering means that it's passed on after every print command. If your output is unbuffered, every byte is transmitted separately, without passing through a holding area.


byte
A piece of data worth eight bits in most places.


bytecode
A pidgin-like language spoken among 'droids when they don't wish to reveal their orientation (see endian). Named after some similar languages spoken (for similar reasons) between compilers and interpreters in the late twentieth century. These languages are characterized by representing everything as a non-architecture-dependent sequence of bytes.


C
A language beloved by many for its inside-out type definitions, inscrutable precedence rules, and heavy overloading of the function-call mechanism. (Well, actually, people first switched to C because they found lower-case identifiers easier to read than upper.) The Perl interpreter is written in C, so it's not surprising that Perl borrowed a few ideas from it.


C preprocessor
The typical C compiler's first pass, which processes lines beginning with # for conditional compilation and macro definition, and does various manipulations of the program text based on the current definitions. Also known as cpp (1).


call by reference
An argument-passing mechanism in which the formal arguments refer directly to the actual arguments, and the subroutine can change the actual arguments by changing the formal arguments. See also call by value.


call by value
An argument-passing mechanism in which the formal arguments refer to a copy of the actual arguments, and the subroutine cannot change the actual arguments by changing the formal arguments. (See also call by reference).


character
A small pattern of bits (usually seven, eight, or sixteen in number) that is the machine's representation of a unit of orthography. Americans typically confuse characters with bytes. So does Perl.


character class
A square-bracketed list of characters used in a regular expression to indicate that any character of the set may occur at this point.


class
A package that either defines methods (subroutines) that deal with objects of your class, or that derives methods from other packages that know how to deal with objects of your class. (Or think they know how.) See also inheritance.


class method
A method that treats the whole class as an object. One sort of class method is a constructor. (A class method is also known as a "static" method in C++ terminology.)


client
In networking, a process that initiates contact with a server process in order to exchange data with it and perhaps receive a service.


closure
An anonymous subroutine that, when generated at run-time, keeps track of the identities of externally visible lexical variables even after those lexical variables have supposedly gone out of scope. They're called "closures" because this sort of behavior gives mathematicians a sense of closure.


CODE
The word "CODE" is returned by the ref function when you apply it to a CV. See CV.


collating sequence
The order that characters sort into. This is used by string comparison routines to decide, for example, where in this glossary to put "collating sequence".


command
In shell programming, the syntactic combination of a program name with its arguments. More loosely, anything you type to a shell (a command interpreter) that starts it doing something. In Perl programming, a statement, which might start with a label, and typically ends with a semicolon.


command buffering
An option in Perl that lets you store up the output of each Perl command and then flush it out as a single request to the operating system. It's enabled by setting the $| variable to a non-zero value. It's used when you don't want data sitting around not going where it's supposed to, which may happen because the default on a file or pipe is to use block buffering. See also buffering.


command-line arguments
The values you supply along with a program name when you tell a shell to execute a command. These values are passed to a Perl script through @ARGV.


command name
The name of the program currently executing, as typed on the command line. In C the command name is passed to the program as the first command-line argument. In Perl, it comes in separately as $0.


comment
A remark that doesn't affect the meaning of the program. In Perl, a comment is introduced by a # character and continues to the end of the line.


compile-time
The time when Perl is trying to make sense of your program, as opposed to when it thinks it knows what your program means and is merely trying to do what it thinks your program says to do. See also run-time.


compiler
Strictly speaking, a program that munches up another program and spits out yet another file containing the program in a more executable form, typically containing native machine instructions. The perl program is not a compiler by this definition, but it does contain a compiler that takes a program and turns it into a more executable form (syntax trees) within the perl process itself, which the interpreter then interprets. There are, however, extension modules to get Perl to act more like a real compiler.


composer
A "constructor" for a thingy that isn't really an object, like an array or a hash. For example, a pair of braces acts as a composer for a hash, and a pair of brackets acts as a composer for an array. See "Creating Hard References" in Chapter 4, References and Nested Data Structures.


concatenation
The process of gluing one cat's nose to another cat's tail. Also, a similar operation on two strings.


conditional
Something "iffy".


connection
In telephony, the temporary electrical circuit between the caller's and the callee's phone. In networking, the same kind of temporary circuit between a client and a server.


construct
As a noun, a piece of syntax made up of smaller pieces. As a transitive verb, to create an object using a constructor.


constructor
A special class method that constructs an object and returns it. Sometimes we use the term loosely to mean a composer.


context
The surroundings, or environment. The context given by the surrounding code determines what kind of data a particular expression is expected to return. The two primary contexts are list context and scalar context. Scalar context is sometimes subdivided into Boolean context, numeric context, and string context. There's also a "don't care" context (which is dealt with in Chapter 2, The Gory Details, if you care).


continuation
The treatment of more than one physical line as a single logical line. Makefile lines are continued by putting a backslash before the newline. Internet message headers are continued by putting a space or tab after the newline. Perl lines do not need any form of continuation mark, because whitespace (including newline) is gleefully ignored. Usually.


core dump
The corpse of a process, in the form of a file left in the working directory of the process, usually as a result of certain kinds of fatal error.


CPAN
Comprehensive Perl Archive Network. (See the Preface for more details.)


current package
Which package the current statement is compiled in. Scan backward in the text of your program until you find a package declaration at the same block level, or in an enclosing block. That's your current package name.


current working directory
See working directory.


currently selected output channel
The last filehandle that was designated with select(FILEHANDLE); the default is STDOUT, if no filehandle has been selected.


CV
An internal "code value" typedef. A CV is a kind of SV.


dangling statement
A bare, single statement, without any braces, hanging off an if or while conditional. C allows them. Perl doesn't.


data flow
What your program looks like from the perspective of a particular piece of data from the time it enters your program to the time it leaves or is combined with some other data to make new data.


data reduction
The process of extracting only the most interesting tidbits because the boss can't read fast enough.


data structure
How your various pieces of data relate to each other, and what shape they make when you put them all together, as in a rectangular table, or a triangular-shaped tree.


data type
A set of possible values, together with all the operations that know how to deal with those values. For example, a numeric data type has a certain set of numbers that you can work with, and it has various mathematical operations you can do on the numbers that would make little sense on, say, a string such as "Kilroy". Strings have their own operations, such as concatenation. Compound types made of a number of smaller pieces generally have operations to compose and decompose them, and perhaps to rearrange them. Objects that model things in the real world often have operations that correspond to real activities. For instance, if you model an elevator, your elevator object might have an open_door() method.


DBM
Stands for "Data Base Management" routines, a set of routines that emulate an associative array using disk files. The routines use a dynamic hashing scheme to locate any entry with only two disk accesses. DBM files allow a Perl script to keep a persistent hash across multiple invocations. You can tie your hash variables to various DBM implementations--see Chapter 5, Packages, Modules, and Object Classes.


declaration
An assertion you make that something exists and perhaps what it's like, without any commitment as to how or where you'll use it. A declaration is like the part of your recipe that says, "two cups flour, one large egg, four or five tadpoles...." See statement for its opposite. Note that some declarations also function as statements.


decrement
To subtract one from something.


default
A value that is chosen for you if you don't supply a value of your own.


defined
Having a meaning. Perl thinks that some of the things people try to do are devoid of meaning; in particular, making use of variables that have never been given a value, and performing certain operations on data that isn't there. For example, if you try to read data past the end of a file, Perl will hand you back an undefined value. See also false.


delimiter
Some character or string that sets bounds to an arbitrarily-sized textual object.


dereference
A fancy computer science term meaning "to follow a reference to what it points to". The "de" part of it refers to the fact that you're taking away one level of indirection.


derived class
A class that defines some of its methods in terms of a more generic class, called a base class. Note that classes aren't classified exclusively into base classes or derived classes: a class can function as both a derived class and a base class simultaneously.


destroy
To deallocate the memory of a thingy.


destructor
A special method that is called when an object is thinking about destroying itself.


device
A whiz-bang hardware gizmo (like a disk or tape drive) attached to your computer that the operating system tries to make look like a file (or a bunch of files). Under UNIX, these fake files tend to live in the /dev directory.


directory
A place where you find files, and perhaps other directories. Some operating systems call these "folders", "drawers", or "catalogs".


directory handle
A name that represents a particular instance of opening a directory to read it, until you close it.


dump
A Perl statement that is one of the many ways to get a Perl program to produce a core dump. Most of the others are undocumented.


dynamic scoping
Making variables visible throughout the rest of the block in which they are first used, as well as within any subroutines that are called by the rest of the block. Dynamically scoped variables can have their values temporarily changed (and implicitly restored later) by a local statement. Compare Lexical Scoping. Used more loosely to mean how a subroutine that is in the middle of calling another subroutine "contains" that subroutine at run-time.


eclectic
Derived from many sources. Some would say too many.


element
A basic building block. When you're talking about an array, it's one of the items that make up the array.


endian
See little-endian and big-endian.


environment
The collective set of environment variables your process inherits from its parent. Accessed via %ENV.


environment variable
A mechanism by which some high-level agent such as a user can pass its preferences down to child processes, grandchild processes, greatgrandchild processes, and so on. Each environment variable is a key/value pair, like one element of a hash.


EOF
End of File. Sometimes used metaphorically as the trailing delimiter of a here document.


errno
The error number returned by a UNIX system call when it fails. Perl refers to the error by the name $! (or $OS_ERROR if you use the English module).


exception
A fancy term for an error. See fatal error.


exception handling
The way a program responds to an error. The exception handling mechanism in Perl is the eval construct.


executable file
A file that is specially marked to tell the operating system that it's OK to run this file as a program. Abbreviated to "executable".


execute
To run a program or subroutine. (Has nothing to do with the kill command, unless you're trying to run a signal handler.)


execute bit
The special mark that tells the operating system it can run this program. There are actually three execute bits under UNIX, and which bit gets used depends on whether you own the file singularly, collectively, or not at all.


exit status
See status.


exponent
The part of a floating-point number that says where to put the decimal point in the other part. See mantissa.


export
To make symbols from your module available for import by other modules.


expression
Anything you can legally say in a spot where a value is required. Typically composed of literals, variables, operators, functions, and subroutine calls.


false
In Perl, any value that would look like "" or "0" if evaluated in a string context. Since undefined values evaluate to "", all undefined values are false, but not all false values are undefined.


fatal error
An error that causes termination of the process after printing a nasty message on your standard error stream. "Fatal" errors that happen inside an eval aren't fatal to the whole program, just to that particular eval. The nasty message then shows up in the $@ variable. You can cause a fatal error with the die operator. This is also known as throwing or raising an exception.


field
A single piece of numeric or string data that is part of a longer string, record, or line. Variable-width fields are usually separated by delimiters (so use split to extract the fields), while fixed-width fields are usually at fixed positions (so use unpack).


file
A named collection of data, usually stored on a disk in a directory. Roughly like a document, if you're into office metaphors. In some operating systems like UNIX, you can actually give a file more than one name.


file descriptor
The little number the operating system uses to keep track of which opened file you're talking about. Perl hides the file descriptor inside a standard I/O stream, and then attaches the stream to a filehandle.


file glob
A "wildcard" match on filenames.


file test operator
A built-in Perl operator that you use to determine whether something is true about a file, such as whether you could open it if you tried.


filehandle
What you pick up a file with. Or, a name (not necessarily related to the real name of a file) that represents a particular instance of opening a file until you close it. Thus if you're going to open and close several different files in succession, it's possible to open each of them with the same filehandle, so you don't have to write out separate code to process each file. It's like the game show host calling someone "Contestant #1" so that he doesn't have to remember too many names from day to day.


filename
The name for a file. This name is listed in a directory, and you can use it in an open statement to tell the operating system exactly which file you want to open.


filesystem
A set of directories and files residing on a partition of the disk. You can move a file around from directory to directory within a filesystem without actually moving the file itself, at least under UNIX.


floating point
A method of storing numbers in scientific notation, such that the precision of the number is independent of its magnitude (the decimal point "floats"). Perl does its numeric work with floating-point numbers, when it can't get away with using integers.


flush
The act of emptying a buffer, often before it's full.


fork
To create a child process identical to the parent process, at least until it gets ideas of its own.


formal arguments
Generic names a subroutine knows its arguments by. In many languages, formal arguments are always given individual names, but in Perl they are passed via arrays. The formal arguments to a Perl program are $ARGV[0], $ARGV[1], and so on. The formal arguments to a Perl subroutine are $_[0], $_[1], and so on. You may give the arguments individual names by assigning the values to a local or my list.


format
A specification of how many spaces and digits and things to put somewhere so that whatever you're printing comes out nice and pretty.


freely available
Means you don't have to pay money to get it, but the copyright on it may still belong to someone else (like Larry).


freely redistributable
Means you're not in trouble if you give a bootleg copy of it to your friends (hint).


function
Mathematically, a mapping of each of a set of input values to a particular output value. In computers, refers to a subroutine or operation that returns a value. It may or may not have input values (called arguments).


garbage collection
A misnamed feature of some programming languages--it should be called "expecting your mother to pick up after you". Strictly speaking, Perl doesn't do this, but relies on a reference counting mechanism to keep things tidy. However, when your interpreter thread exits, a kind of garbage collector runs to make sure everything is cleaned up if you've been messy with circular references and such.


GID
Group ID--in UNIX, the numeric group ID that the operating system uses to identify you and members of your group.


glob
Strictly, the shell's * character, which will match a "glob" of characters when you're trying to generate a list of filenames. Loosely, the act of using globs and similar symbols to do pattern matching.


global
Something you can see from anywhere, usually used of variables and subroutines that are visible everywhere in your program. In Perl, only certain special variables are truly global--most variables (and all subroutines) are local to the current package.


group
A set of users that you're a member of. In some operating systems (like UNIX), you can give certain file access permissions to other members of your group.


GV
An internal "glob value", meaning a typeglob. A GV is a kind of SV.


hard reference
A scalar value containing the actual address of a thingy, such that the thingy's reference count accounts for it. (Some hard references are held internally, such as the implicit reference from one of a typeglob's variable slots to its corresponding thingy.) A hard reference is different from a symbolic reference.


has-a
A relationship between two objects that is more tenuous than an is-a relationship, and that can be modeled by containment of one object in another (which in Perl means containment of a reference to the contained object.) You generally don't want to use inheritance to model the has-a relationship because methods that make sense on the contained object probably don't make sense on the object as a whole. Just because your car has-a brake pedal doesn't mean you should stomp on your car.


hash
A named list of key/value pairs, arranged such that you can easily use any key to find its associated value; a binary relation, to database users. This glossary is like a hash, where the word to be defined is the key, and the definition is the value. A hash is also sometimes called an "associative array". (Which is a good reason for calling it a hash instead.)


hash table
A method used internally by Perl for implementing associative arrays (hashes) efficiently.


header file
A file containing certain required definitions that you must include "ahead" of the rest of your program to do certain obscure operations. A C header file has a .h extension. A Perl header file has a .ph extension. See the require operator in Chapter 3, Functions. (Header files have been superseded by the module mechanism.)


here document
So called because of a similar construct in shells which pretends that the lines "right here" following the command are a separate file to be fed to the command, up to some trailing delimiter string. In Perl, however, it's just a fancy form of quoting.


hexadecimal
A number in base sixteen, "hex" for short. The digits for ten through sixteen are customarily represented by the letters a through f. Hexadecimal constants in Perl start with 0x.


home directory
The directory you are placed into when you log in. On a UNIX system, the name is often placed into $ENV{HOME} or $ENV{LOGDIR} by the login program, but you can also find it with (getpwuid($<))[7].


host
The computer on which a program or other data resides.


hubris
Excessive pride, the sort of thing Zeus zaps you for. Also the quality that makes you write (and maintain) programs that other people won't want to say bad things about. Hence, the third great virtue of a programmer. See also laziness and impatience.


HV
Short for "hash value," which refers to one of Perl's internal data types. An AV is a kind of SV.


identifier
A legally formed name for most anything in which a computer program might be interested. Many languages (including Perl) allow identifiers that start with a letter and contain letters and digits. Perl also counts the underscore character as a valid letter.


impatience
The anger you feel when the computer is being lazy. This makes you write programs that don't just react to your needs, but actually anticipate them. Or at least that pretend to. Hence, the second great virtue of a programmer. See also laziness and hubris.


import
Gain access to symbols that are exported from another module. See the use operator in Chapter 3, Functions.


increment
To add one to something.


indexing
Formerly, the act of looking up a key in an index (like the phone book), but now merely the act of using any kind of key or position to find the corresponding value, even if no index is involved. Things have degenerated to the point that Perl's index function merely locates the position (index) of one string in another.


indirect object
In English grammar, a short noun phrase between a verb and its direct object indicating the beneficiary or recipient of the action. In Perl, print STDOUT `$foo\n`; can be understood as verb indirect-object object where STDOUT is the recipient of the print action, and "$foo" is the object being printed. Similarly, when invoking a class method, you might say:


% perl
sub Bob::give { shift; print
"Thanks for the @_!\n"; }
give Bob memories
^D
Thanks for the memories!


indirection
When Randal says, "I don't know the answer... go ask Larry." Similarly, if something in a program isn't the answer, but indicates where the answer is, that's indirection. This can be done with symbolic or hard references.


inheritance
What you get from your ancestors, genetically or otherwise. If you happen to be a class, your ancestors are called base classes and your descendants are called derived classes. See single inheritance and multiple inheritance.


integer
Number with no fractional part; whole number.


interpolation
The insertion of one piece of text somewhere in the middle of another piece of text. The inserted piece may derive from a variable or other indirect source.


interpreter
Strictly speaking, a program that reads a second program and does what the second program says directly without turning the program into a different form first, which is what compilers do. Perl is not an interpreter by this definition, because it contains a kind of compiler that takes a program and turns it into a more executable form (syntax trees) within the Perl process itself, which the Perl run-time system then interprets.


invocation
The act of calling up a program, subroutine, or function to do what it's supposed to do.


IPC
Short for Inter-Process Communication. Sometimes a process just needs to talk to some other process.


is-a
A relationship between two objects in which one object is considered to be a more specific version of the other generic object: "A camel is a mammal." Since the generic object really only exists in a platonic sense, we usually add a little abstraction to the notion of objects and think of the relationship as being between a generic base class and a specific derived class. Oddly enough, platonic classes don't always have platonic relationships--see inheritance.


iteration
Doing something again and again and again and again and again and.... Usually this is done until you're loopy, which is why they call them loops.[3]

[3] We'd put in the usual joke referring you back to Iteration, but that trick has been iterated too often already, and is no longer funny. Look for the joke under Loop instead. Also look for a similar joke under Recursion, which is still funny at some level or other.


iterator
A special programming gizmo that keeps track for you of where you are in something that you're trying to iterate over. The foreach loop in Perl contains an iterator.


key
A special kind of data, such as your Social Security number, that can be used to locate other data. The other data may be considered the value associated with the key.


keyword
See reserved word.


label
A kind of key you can give to a statement so that you can talk about that statement elsewhere in the program.


laziness
The quality that makes you go to great effort to reduce overall energy expenditure. It makes you write labor-saving programs that other people will find useful, and document what you wrote so you don't have to answer so many questions about it. Hence, the first great virtue of a programmer. Also hence, this book. See also impatience and hubris.


left shift
A bit shift that multiplies the number by some power of two.


lexical scoping
Looking at your Oxford English Dictionary through a microscope. (Also known as static scoping, because dictionaries don't change very fast.) Similarly, looking at variables that are stored in a private dictionary for each subroutine, which are visible only from their point of declaration down to the end of the block in which they are declared. --Syn. static scoping. --Ant. dynamic scoping. [< Gk]


library
A collection of procedures. In ancient days, referred to a collection of subroutines in a .pl file. In modern times, refers often to the entire collection of Perl modules on your system.


line
In UNIX, a sequence of zero or more non-newline characters terminated with a newline character. On non-UNIX machines, this is emulated even if the underlying operating system has different ideas.


line buffering
Used by a standard I/O output stream that flushes its buffer after every newline. Many standard I/O libraries automatically set this up on output that is going to the terminal.


line number
The number of lines read prior to this one, plus 1. Perl keeps a separate line number for each script or input file it opens. The current script line number is represented by _ _LINE_ _. The current input line number (for the file that was most recently read from via <>) is represented by the $. variable. Many error messages report both values, if available.


link
In UNIX, a name in a directory, representing a file. A given file can have multiple links to it. It's like having the same phone number listed in the phone directory under different names.


list
An ordered set of values.


LIST
A syntactic construct representing a comma-separated list of expressions, evaluated to produce a list value. Each expression in a LIST is evaluated in a list context.


list context
The situation in which an expression is expected by its surroundings (the code calling it) to return a list of values rather than a single value. Functions that want a LIST of arguments tell those arguments that they should produce a list value. See also context.


list operator
Generally, an operator that does something with a list of values. Specifically, those operators (such as print, unlink, and system) that do not require parentheses around their argument list.


list value
An unnamed list of scalar values that may be passed around within a program and passed to any function that provides a list context.


literal
Often means "figurative", as in "I'm literally scared to death." More literally, a symbol in a programming language like a number or string that gives you an actual value instead of merely representing possible values like a variable.


little-endian
From Swift: someone who eats boiled eggs little end first. Also used of computers that store the least significant byte of a word at a lower byte address than the most significant byte. Often considered superior to big-endian machines. See also big-endian.


local
Not meaning the same thing everywhere. A variable in Perl can be localized inside a block or a package. See scope.


logical operator
Symbols representing the concepts "and", "or", and "not".


loop
A construct that performs something repeatedly, like a roller coaster. (Go to the next entry if you're tired of riding this one.) See loop.


loop control statement
Any statement within the body of a loop that can make a loop stop looping or skip an iteration. See the middle sentence of the previous entry. Generally you shouldn't try this on roller coasters without a parachute.


loop label
A kind of key or name attached to a loop so that loop control statements can talk about which loop they want to control.


lvalue
Term used by language-lawyers for a location you can assign a new value to, such as a variable or an element of an array. The "l" is short for "left", as in the left side of an assignment, a typical place for lvalues.


magical increment
An increment operator that knows how to add 1 to alphanumeric strings as well as to numbers.


magical variables
Special variables that have side effects when you access them or assign to them. For example, in Perl, changing elements of the %ENV array also changes the corresponding environment variables that subprocesses will use. Reading the $! variable gives you the current UNIX error number or message.


manpage
A "page" from the UNIX manuals, typically accessed online via the man (1) command. A manpage contains a synopsis, a description, a list of bugs, and so on, and is typically longer than a page. There are manpages documenting commands, system calls, library functions, devices, protocols, files, and such.


mantissa
The part of a floating-point number that gives the digits of the number without saying where the decimal point really belongs. See exponent.


matching
See pattern matching.


metacharacter
A character that is not supposed to be treated normally. Which characters are to be treated specially as metacharacters varies greatly from context to context. Your shell will have certain metacharacters, double-quoted Perl strings have other metacharacters, and patterns have all the double-quote metacharacters plus some extra ones. In addition, people sometimes use this term to describe characters that have the eighth bit set.


method
A kind of action that an object can take if you direct it to.


minimalism
The belief that "small is beautiful." Paradoxically, if you say something in a small language, it turns out big, and if you say it in a big language, it turns out small. Go figure.


mode
In the context of the stat (2) system call, refers to the word holding the permissions and the type of the file.


modifier
A conditional or loop that you put after the statement instead of before, if you know what I mean.


module
A file that defines a package of (almost) the same name, which can either export symbols or function as an object class. The unit of reusability in Perl. See the use operator.


modulus
A divisor, when you're interested in the remainder instead of the quotient.


multi-dimensional array
An array with multiple subscripts for finding a single element. Perl does them with references--see Chapter 4, References and Nested Data Structures.


multiple inheritance
The features you got from your mother and father, mixed together unpredictably. (See also inheritance, and single inheritance.) In computer languages (including Perl), the notion that a given class may have multiple direct ancestors or base classes.


namespace
A domain of names. You needn't worry whether the names in one such domain have been used in another. See package.


network address
The most important attribute of a socket, like your telephone's telephone number.


newline
A single character that represents the end of a line, with the ASCII value of 012 octal under UNIX (but 015 on a Mac), and represented by \n in Perl strings. For certain physical devices like terminals, this gets translated to a line feed and a carriage return.


null character
A character with the ASCII value of zero. It's used by C and some UNIX system calls to terminate strings, but Perl allows strings to contain a null.


null list
A list value with zero elements, represented in Perl by ().


null string
A string not containing any characters, not to be confused with a string containing a null character, which has a positive length.


numeric context
The situation in which an expression is expected by its surroundings (the code calling it) to return a number. See also context and string context.


nybble
Half a byte, equivalent to one hexadecimal digit.


object
Something that "knows" what kind of thing it is, and what it can do because of what kind of thing it is. Your program can request an object to do things, but the object gets to decide whether it wants to do it or not.


octal
A number in base eight. Only the digits zero through seven are allowed. Octal constants in Perl start with zero, as in 013.


offset
How many things you have to skip over when moving from the beginning of a string or array to a specific position within it. Thus, the minimum offset is zero, not one, because you don't skip anything to get to the first item.


operand
You, after you dial the operator on your phone. Or, an expression that gives a value that an operator operates on. See also precedence.


operating system
A special program that runs on the bare machine and hides the gory details of managing processes and devices. It is usually used in a looser sense to indicate a particular culture of programming. The loose sense can be used at varying levels of specificity. At one extreme, you might say that all versions of UNIX and UNIX-lookalikes are the same operating system (upsetting many people, especially some lawyers). At the other extreme, this particular version of this particular vendor's operating system is different than any other version of this or any other vendor's operating system. Perl is much more portable across operating systems than many other languages. See also architecture.


operator
A function, generally one that is built into a language, often with a special syntax or symbol. A given operator may have specific expectations about what types of data you give as its arguments (operands) and what type of data you want back from it.


operator overloading
A kind of overloading that you can do on the built-in operators to make them work (syntactically) on objects as if they were ordinary scalar values, but with the actual semantics supplied by the object class. This is set up with the overload pragma--see Chapter 7, The Standard Perl Library.


options
See switches.


overloading
Giving additional meanings to a symbol or construct. Actually, all languages do overloading to one extent or another, since people are good at figuring out things from context. If you look in your dictionary, you will find that the meaning of the word "single" is not single.


overriding
Hiding or invalidating some other definition of the same name. (Not to be confused with overloading, which only adds definitions.) To confuse the issue further, we use the word with two overloaded definitions: to describe how you can define your own subroutine that hides a built-in function of the same name, and also to describe how you can define a replacement method in a derived class that hides a base class 's method of the same name. You'll find both of these usages in Chapter 5, Packages, Modules, and Object Classes.


owner
The one user (apart from the superuser) who has absolute control over a file. A file may also have a group of users that may exercise joint ownership if the real owner permits them. See permission flags.


package
A quantity of code that values its privacy, and tries to keep other code from trespassing upon its namespace by fencing all of its private belongings (variables and subroutines) into its own area. A variable or subroutine mentioned in the package belongs only to that package, even if there's another variable or subroutine with an identical name in some other package.


package local
A variable or subroutine belonging to a package and not visible to anyone else. At least, not without peeking. See namespace.


parameter
See argument.


parsing
The subtle but sometimes brutal art of attempting to turn your possibly malformed program into a valid syntax tree.


PATH
The list of directories the system looks in to find a program you want to execute. The list is stored as one of your environment variables, accessible in Perl as $ENV{PATH}.


pathname
A fully qualified filename such as /usr/bin/perl or C:\my_apps\perl.exe. Sometimes confused with PATH.


pattern matching
Taking a pattern, expressed as a regular expression, and trying the pattern various ways on a string to see if there's any way to make it fit. Often used to pick interesting tidbits out of a file.


permission flags
Bits that the owner of a file sets or unsets in order to allow or disallow access to other people. These flags are part of the mode word returned by the stat operator when you ask about a file. On UNIX systems you can check the ls (1) manpage for more information about the permission flags.


Pern
What you get when you do Perl++ twice. Increment it only once, and your hair curls. Increment it three times, and you get a tasty beverage that isn't Java. See also slice.


pipe
A direct connection that carries the output of one process to the input of another without the necessity of an intermediate temporary file. Once the pipe is set up, the two processes in question can mostly read and write as if they were talking to a normal file.


pipeline
A series of processes all in a row, linked by pipes, where each passes its output to the next.


pointer
A variable in a language like C that contains the exact memory location of some other item. Perl handles pointers internally so you don't have to worry about them. Instead, you just use symbolic pointers in the form of keys and variable names, or hard references, which aren't pointers (but act like pointers, and do in fact contain pointers).


port
The part of the address of a TCP or UDP socket that directs packets to the correct process after finding the right machine, something like the phone extension number you give when you reach the company operator.


pragma
A library module whose practical hints and suggestions are received (and possibly ignored) by the compiler. [< Gr]


precedence
The rules of conduct that, in the absence of other guidance, determine what should happen first (i.e., in the absence of parentheses, you always do multiplication before addition).


preprocessing
What some other helper process did to transform the incoming data into a form more suitable for the current process. Often done with an incoming pipe. See also C preprocessor.


procedure
A subroutine.


process
An instance of a running program. Under multi-tasking systems like UNIX, two or more separate processes could be running the same program independently at the same time--in fact, the fork function is designed to bring about this happy state of affairs. Under other operating systems processes are sometimes called "tasks" or "jobs".


protocol
In networking, an agreed-upon way of sending messages back and forth so that neither correspondent will get too confused.


pseudo literal
An operator that looks something like a literal, such as the output-grabbing operator, `command`.


pseudo terminal
A thing that looks like an ordinary terminal to the computer, but instead of being attached to a real terminal, is really attached to another computer program, which is doing the pseudotyping.


public domain
Something not owned by anybody. Perl is copyrighted, and is thus not in the public domain--it's just freely available and freely redistributable.


PV
A "pointer value", which is Perl Internals Talk for a char*.


qualified
Possessing an explicit package name. The symbol $ex::loser is qualified; $loser is unqualified.


readable
With regard to files, one that has the proper permission bit set to let you access the file. With regard to computer programs, one that's well enough written that someone can come back later and have a chance of figuring out what it's trying to do. Who knows, you might even have to come back and figure out your own program.


record
A set of related data values in a file or stream, often associated with a unique key field. In UNIX, often commensurate with a line, or a blank-line-delimited set of lines (a "paragraph"). Each line of the /etc/passwd file is a record, keyed on login name, containing information about that user.


recursion
The art of defining something (at least partly) in terms of itself by means of recursion, which is a naughty no-no in dictionaries.


reference
A place you look to find a pointer to information stored somewhere else. (See indirection.) References come in two flavors, symbolic references, and hard references.


regular expression
A single entity with various interpretations, like an elephant. To a computer scientist, it's a grammar for a little language in which some strings are legal and others aren't. To normal people, it's a pattern that you can use to find what you're looking for when it varies from case to case. Example of a regular expression:


/Oh s.*t./

This pattern will match strings like `Oh say can you see by the dawn's early light,` and `Oh sit!`. See the section "Regular Expressions" in Chapter 2, The Gory Details.


regular file
A file that's not a directory, a device, a named pipe or socket, or a symbolic link. Perl uses the -f file test operator to identify regular files.


relation
Jargon used by relational database folks to mean a file--albeit a particular sort of file, tabular in form, in which all the tuples (records) are of the same kind, each containing the same domains (keys) and ranges (fields). The UNIX /etc/passwd file is a relation keyed on login name. It's called a relation because it relates keys and fields in much the same way as an hash associates keys and values.


relational operator
An operator that says whether a particular ordering relationship is true about a pair of operands. Perl has both numeric and string relational operators. See collating sequence.


reserved words
A word with a specific, built-in meaning to a compiler, such as if or delete. In many languages (not Perl) it's illegal to use reserved words to name anything else. (Which is why they're reserved, after all.) In Perl, you just can't use them to name labels or filehandles. Also called "keywords".


return value
The value produced by a subroutine or expression when evaluated. In Perl, a return value may be either a list or a scalar value. The subroutine call piglatin('bingo') returns the value "ingobay".


right shift
A bit shift that divides a number by some power of two.


run-time
The time when Perl is actually doing what your script says to do, as opposed to the earlier period of time when it was trying to figure out whether what you said made any sense whatsoever. See also compile-time.


run-time pattern
A pattern that contains one or more variables to be interpolated before parsing the pattern as a regular expression, and that therefore cannot be analyzed at compile time, but must be re-analyzed each time the pattern match operator is evaluated. Run-time patterns are useful but expensive.


rvalue
A value that you might find on the right side of an assignment. See also lvalue.


scalar
A simple value, such as a number or string.


scalar context
The situation in which an expression is expected by its surroundings (the code calling it) to return a single value rather than a list of values. See also context and list context. A scalar context sometimes imposes additional constraints on the return value--see string context and numeric context. Sometimes we talk about a Boolean context inside conditionals, but this imposes no additional constraints, since any scalar value, whether numeric or string, is already true or false.


scalar literal
A number or quoted string--an actual value in the text of your program, as opposed to a variable.


scalar value
A value that happens to be a scalar as opposed to a list.


scalar variable
A variable prefixed with $ that holds a single value.


scope
How far away you can see a variable from, looking through one. Perl has two visibility mechanisms: it does dynamic scoping of local variables, meaning that the rest of the block, and any subroutines that are called by the rest of the block, can see the variables that are local to the block. Perl does lexical scoping of my variables, meaning that the rest of the block can see the variable, but other subroutines called by the block cannot see the variable.


script
A text file that is a program intended to be executed directly rather than compiled to another form of file before execution.


sed
A venerable stream editor from which Perl derives some of its ideas.


server
In networking, a process that either advertises a service or just hangs around at a known location and waits for clients who need service to get in touch with it.


service
Something you do for someone else to make them happy, like giving them the time of day (or of their life). On some UNIX machines, well-known services are listed by the getservent function.


setgid
Same as setuid, only having to do with giving away group privileges.


setuid
Said of a program that runs with the privileges of its owner rather than (as is usually the case) the privileges of whoever is running it. Also describes the bit in the mode word (permission flags) that implements the feature. This bit must be explicitly set by the owner to implement this feature, and the program must be written not to give away more privileges than it ought.


shell
A command-line interpreter. The program that interactively gives you a prompt, accepts one or more lines of input, and executes the programs you mentioned, feeding each of them their proper arguments and input data. Shells can also execute scripts containing such commands. Under the UNIX operating system, typical shells are the Bourne shell (/bin/sh), the C shell (/bin/csh), and the Korn shell (/bin/ksh). Perl is not strictly a shell because it's not interactive (although Perl programs can be interactive).


side effects
Something extra that happens when you evaluate an expression. Nowadays it can refer to almost anything. For example, evaluating a simple assignment statement typically has the "side effect" of assigning a value to a variable. (And you thought assigning the value was your primary intent in the first place!) Likewise, assigning a value to the special variable $| has the side effect of forcing a flush after every write or print on the currently selected filehandle.


signal handler
A subroutine that, instead of being content to be called in the normal fashion, sits around waiting for a bolt out of the blue before it will deign to execute. Under UNIX, bolts out of the blue are called signals, and you send them with a kill command.


single inheritance
The features you got from your mother, if she told you you don't have a father. (See also inheritance, and multiple inheritance.) In computer languages, the notion that classes reproduce asexually, so that a given class can only have one direct ancestor or base class. Perl enforces no such restriction.


slice
A selection of array elements.


socket
An endpoint for network communication between two processes, that works much like a telephone. The most important thing about a socket is its network address (like a phone number). Different kinds of sockets have different kinds of addresses--some look like filenames, and some don't.


soft reference
See symbolic reference.


standard error
The default output stream for making nasty remarks that don't belong in standard output. Represented within a Perl program by the filehandle STDERR. You can use this stream explicitly, but the operators die and warn write to your standard error stream automatically.


standard I/O
A standard C library for doing buffered input and output to the operating system. (The "standard" of standard I/O is only marginally related to the "standard" of standard input and output.) In general, Perl relies on whatever implementation of standard I/O a given operating system supplies, so the buffering characteristics of a Perl program on one machine may not exactly match those on another machine. Normally this only influences efficiency, not semantics. If your standard I/O package is doing block buffering and you want it to flush the buffer more often, just set the $| variable to a nonzero value.


standard input
The default input stream for your program, which if possible shouldn't care where its data is coming from. Represented within a Perl program by the filehandle STDIN.


standard output
The default output stream for your program, which if possible shouldn't care where its data is going. Represented within a Perl program by the filehandle STDOUT.


stat structure
A special internal buffer in which Perl keeps the information about the last file you requested information on.


statement
A command to the computer about what to do next, like a step in a recipe: "Add marmalade to batter and mix until mixed." Not to be confused with a declaration, which doesn't tell the computer to do anything, but just to learn something.


static
Varying slowly, compared to something else. (Unfortunately, everything is relatively stable compared to something else, except for certain elementary particles, and we're not so sure about them.) In computers, where things are supposed to vary rapidly, "static" has a derogatory connotation, indicating a slightly dysfunctional variable, subroutine, or method. In Perl culture, the word is considered to be politically incorrect.


static method
See class method.


static scoping
Same as lexical scoping.


status
The value returned to the parent process when one of its child processes dies. This value is placed in the special variable $?. Its upper eight bits are the exit status of the defunct process, and its lower eight bits identify the signal (if any) that the process died from. On UNIX systems, this status value is the same as the status word returned by wait (2). See system in Chapter 3, Functions.


STDERR
See standard error.


STDIN
See standard input.


STDIO
See standard I/O.


STDOUT
See standard output.


string
A sequence of characters such as "He said !@#*&%@#*?\n." A string does not have to be entirely printable.


string context
The situation in which an expression is expected by its surroundings (the code calling it) to return a string. See also context and numeric context.


struct
C keyword introducing a structure definition or name.


structure
See data structure.


subclass
See derived class.


subroutine
A named piece of program that can be invoked from elsewhere in the program in order to accomplish some sub-goal of the program. A subroutine is often parameterized to accomplish different but related things depending on its input arguments. If the subroutine returns a meaningful value, it is also called a function.


subscript
A value that indicates the position of a particular array element in an array.


substring
A portion of a string, starting at a certain character position (offset), and proceeding for a certain number of characters.


superclass
See base class.


superuser
The person whom the operating system will let do almost anything. Typically your system administrator or someone pretending to be your system administrator. On UNIX systems, the root user.


SV
Short for "scalar value". But within the Perl interpreter every thingy is treated as a kind of SV, in an object-oriented sort of way. Every value inside Perl is passed around as an SV* pointer in C. The SV struct knows its own "thingy type", and the code is smart enough (we hope) not to try to call a hash function on a subroutine.


switch
An option you give on a command line to influence the way your program works. In UNIX, these are usually introduced with a minus sign. The word is also used as a nickname for a switch statement.


switch clustering
The combining of multiple command line switches -a -b -c into one switch -abc. In Perl, any switch with an additional argument must be the last switch in a cluster.


switch statement
A program construct that lets you evaluate an expression and, based on the expression's value, do a multi-way branch to the appropriate piece of code for that value. Also called a "case structure", after the similar Pascal construct.


symbol table
Where a compiler remembers symbols. A program like Perl must somehow remember all the names of all the variables, filehandles, and subroutines you've used. It does this by placing the names in a symbol table, which is implemented in Perl using a hash table. There is a separate symbol table for each package, to give each package its own namespace.


symbolic debugger
A program that lets you step through the execution of your program, stopping or printing things out here and there to see if anything has gone wrong, and if so, what. The "symbolic" part just means that you can talk to the debugger using the same symbols in which your program is written.


symbolic link
An alternate filename that points to the real filename. Whenever the operating system is trying to parse a pathname containing a symbolic link, it merely substitutes the real name and continues parsing.


symbolic reference
A variable whose value is the name of another variable or subroutine. By dereferencing the first variable, you can get at the second one.


syntax
From Greek, "with-arrangement". How things (particularly symbols) are put together with each other.


syntax tree
An internal representation of your program wherein lower-level constructs dangle off the higher-level constructs enclosing them.


system call
A subroutine call directly to the operating system. Many of the important subroutines and functions you use aren't direct system calls, but are built up in one or more layers above the system call level. In general, Perl users don't need to worry about the distinction.


tainted
Said of data that might be derived from the grubby hands of a user, and thus unsafe for a secure program to rely on. Perl does taint checks if you run a setuid program or use the -T switch.


TCP
Short for Transmission Control Protocol. A protocol wrapped around the Internet Protocol to make an unreliable packet transmission mechanism appear to the application program to be a reliable stream of bytes. (Well, usually.)


text
Normally, a string or file containing primarily printable characters. The word has been usurped in some UNIX circles to mean the portion of your process that contains machine code to be executed.


thingy
Something sort of like an object, that you may or may not know the name of, but that you can refer to with circumlocutions like "that hangy-down thingy that dangles in the back of your throat". Similarly in Perl, a value that is sort of like an object, that you may or may not know the name of, but that you can refer to via references from which the thingy dangles, metaphorically speaking. Specifically, the sort of value that your reference points to when you create a reference to a variable. See anonymous, hard reference, and object, not necessarily in that order.


thread
An instance of running a program, but lighter weight than a process, in that a process could have multiple threads running around in it, all sharing the same process's resources. (If you're a dragonrider, see Pern.)


tie
The bond between a magical variable and its implementation class. See the tie function in Chapters 3 and 5.


tokenizing
Splitting up a program text into its separate words and symbols, each of which is called a token. Also known as "lexing", in which case you get "lexemes" instead of tokens.


toolbox approach
The notion that, with a complete set of simple tools that work well together, you can build almost anything you want. Which is fine if you're assembling a tricycle, but if you're building a defranishizing comboflux, you really want your own machine shop to build special tools in. Perl is sort of a machine shop.


true
See false. (And hold it up to a mirror for the secret message.)


tuple
In the lingo of relational databases, a record or line containing fields. See relation.


type
See data type.


type casting
Converting data explicitly from one type to another. C permits this. Perl does not need it.


typeglob
Used of a single identifier, prefaced with * (for example, *name), to stand for any or all of $name, @name, %name, &name, or just name. How you use it determines whether it is interpreted as all of those, or only one of them. See "Typeglobs and Filehandles" in Chapter 2, The Gory Details.


UID
A User ID. Often used in the context of file ownership.


unary operator
An operator with only one operand, like ! or chdir. Unary operators are usually prefix operators, that is, they precede their operand. The ++ and - - operators can be either prefix or postfix. (Of course, that does change their meaning.)


undefined
Nobody has ever given this a reasonable definition. See also defined.


UNIX
A very large and constantly evolving language with several alternate and largely incompatible syntaxes, in which anyone can define anything any way they choose, and usually do. Speakers of this language think it's easy to learn because it's so easily twisted to one's own ends, but dialectical differences make tribal intercommunication nearly impossible, and travelers are often reduced to a pidgin-like subset of the language. To be universally understood, a UNIX shell programmer must spend years of study in the art. Many have abandoned this discipline and now communicate via an Esperanto-like language called Perl. In ancient times UNIX was also used to refer to some code that a couple of people at Bell Labs wrote to make use of a PDP-7 computer that wasn't doing much of anything else at the time.


unqualified
See qualified.


value
This is hard to define. It's something like real data--the actual numbers and strings that wander around in your program. But we don't really need to define it. If you didn't know a value when you see it, you wouldn't have this book. :-)


variable
A named storage location that can hold any of various values, as your program sees fit.


variable interpolation
See interpolation.


vector
Mathematical jargon for a list of scalar values.


warning
A message printed to the STDERR stream to the effect that something might be wrong but it isn't worth blowing up over. See the warn operator in Chapter 3, Functions.


whitespace
A character that moves your cursor around but doesn't otherwise put anything on your screen. Typically refers to any of the following: space, tab, line feed, carriage return, form feed, or vertical tab.


word
In normal "computerese", the piece of data of the size most efficiently dealt with by your computer, typically 32 bits or so, give or take a few powers of two. In UNIX culture, it more often refers to an alphanumeric identifier, or to a string of non-whitespace characters bounded by whitespace or line boundaries.


working directory
Your current directory, from which relative pathnames are interpreted by the operating system. The operating system knows your current directory because you told it with a chdir, or because you started out in the same place where your parent process was when you were born.


wrapper
A program that runs some other program for you, modifying some of its input or output to better suit your purposes. More generally, just about anything that wraps things up. And that just about wraps things up, except for the excess.


XS
An extraordinarily exported, expeditiously excellent, expressly eXternal Subroutine, executed in existing C or C++, or in an exciting new extension language called (exasperatingly) XS. Examine Chapter 6, Social Engineering, for the exact explanation. Exeunt.
mic64 目前離線  
送花文章: 0, 收花文章: 21 篇, 收花: 61 次
 


主題工具
顯示模式

發表規則
不可以發文
不可以回覆主題
不可以上傳附加檔案
不可以編輯您的文章

論壇啟用 BB 語法
論壇啟用 表情符號
論壇啟用 [IMG] 語法
論壇禁用 HTML 語法
Trackbacks are 禁用
Pingbacks are 禁用
Refbacks are 禁用

相似的主題
主題 主題作者 討論區 回覆 最後發表
windwos如何執行Perl或CGI 飛鳥 網路疑難應用技術研討區 1 2005-10-08 12:50 AM
2.網路管理語言 Perl 的簡介 飛鳥 網路疑難應用技術研討區 0 2005-10-07 09:39 AM
perltoot - Tom's object-oriented tutorial for perl mic64 作業系統操作技術文件 0 2004-05-20 01:18 PM


所有時間均為台北時間。現在的時間是 10:32 PM


Powered by vBulletin® 版本 3.6.8
版權所有 ©2000 - 2020, Jelsoft Enterprises Ltd.


SEO by vBSEO 3.6.1