|
277 |
||||||||||||||
|
Chapter 20: |
||||||||||||||
|
Reserved Words |
||||||||||||||
|
"When I |
||||||||||||||
|
- Lewis Carroll, Through the Looking Glass |
||||||||||||||
|
This chapter provides a "Quick Reference" to Perl's "reserved words" or |
||||||||||||||
|
The chapter is organized into the following sections: |
||||||||||||||
|
||||||||||||||
|
||||||||||||||
|
||||||||||||||
|
Space considerations (and the desire not to reproduce what may be better |
||||||||||||||
|
|
||||||||
|
In particular cases, we have provided more detailed information. We have |
||||||||
|
In addition, we have provided synopses for those Perl functions which we |
||||||||
|
For explanations of the rest of the built-in functions and more information |
||||||||
|
For more information on the Mac OS Interface functions module, as well as |
||||||||
|
In each section, all names are given in Courier |
||||||||
|
||||||||
|
||||||||
|
||||||||
|
||||||||
|
|
||||
|
Alphabetical List |
||||
|
|
|||||||||||||||||||
|
s///, scalar, seek, seekdir, select, semctl, semget, semop, send, |
|||||||||||||||||||
|
The built-in functions are categorized below by type (e.g., Data Manipu- |
|||||||||||||||||||
|
Data Manipulation - Numeric |
|||||||||||||||||||
|
rand |
srand |
||||||||||||||||||
|
Data Manipulation - Conversion |
|||||||||||||||||||
|
pack |
vec |
||||||||||||||||||
|
Data Manipulation - Lists (any) |
|||||||||||||||||||
|
scalar |
split |
||||||||||||||||||
|
Data Manipulation - Lists (@array) |
|||||||||||||||||||
|
unshift |
|||||||||||||||||||
|
|
||||||||||||||||||||||
|
Data Manipulation - Lists (%hash) |
||||||||||||||||||||||
|
values |
||||||||||||||||||||||
|
Data Manipulation - Time |
||||||||||||||||||||||
|
time |
times |
|||||||||||||||||||||
|
Data Manipulation - Strings and Patterns |
||||||||||||||||||||||
|
tr/// |
||||||||||||||||||||||
|
Functions, Modules, and Classes |
||||||||||||||||||||||
|
require |
tied |
|||||||||||||||||||||
|
Group/User data |
||||||||||||||||||||||
|
getgrgid |
getpwnam |
setpwent |
||||||||||||||||||||
|
Input/Output - File System |
||||||||||||||||||||||
|
rmdir |
unlink |
|||||||||||||||||||||
|
Input/Output - File |
||||||||||||||||||||||
|
open |
select |
|||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
Input/Output - Directory |
||||||||||||||||||||||||||||
|
seekdir |
||||||||||||||||||||||||||||
|
Mac OS Interface |
||||||||||||||||||||||||||||
|
GetFileInfo |
Quit |
|||||||||||||||||||||||||||
|
Miscellaneous |
||||||||||||||||||||||||||||
|
eval |
ref |
sort |
||||||||||||||||||||||||||
|
Network Protocols |
||||||||||||||||||||||||||||
|
getprotobynumber |
setprotoent |
|||||||||||||||||||||||||||
|
Networking - Sockets |
||||||||||||||||||||||||||||
|
getnetbyname |
recv |
|||||||||||||||||||||||||||
|
Networking - System V |
||||||||||||||||||||||||||||
|
semop |
shmread |
|||||||||||||||||||||||||||
|
Process management |
||||||||||||||||||||||||||||
|
setpgrp |
wait |
|||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
die |
getppid |
syscall |
||||||||||||||||||||||||||
|
Control Flow Modifiers |
||||||||||||||||||||||||||||
|
The control flow modifiers include commands for selection (conditional |
||||||||||||||||||||||||||||
|
continue |
foreach |
next |
while |
|||||||||||||||||||||||||
|
Inline execution (`backquoted commands`) |
||||||||||||||||||||||||||||
|
MacPerl has a limited capability to handle constructs like `command`, |
||||||||||||||||||||||||||||
|
These commands may not be portable to platforms other than Mac OS. |
||||||||||||||||||||||||||||
|
`Directory` |
`hostname` |
`stty raw` |
||||||||||||||||||||||||||
|
Answer |
||||||||||||||||||||||||||||
|
MacPerl::Answer(PROMPT) |
||||||||||||||||||||||||||||
|
Puts up a dialog box with a message (PROMPT) and a choice of 1, 2, or 3 |
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
1 |
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||
|
Ask |
||||||||||||||||||||
|
MacPerl::Ask(PROMPT, DEFAULT) |
||||||||||||||||||||
|
Asks the user for a string. Returns undef |
||||||||||||||||||||
|
chdir |
||||||||||||||||||||
|
chdir(EXPR) |
||||||||||||||||||||
|
Changes the working directory to EXPR, if possible. |
||||||||||||||||||||
|
chmod |
||||||||||||||||||||
|
chmod(EXPR, FILE) |
||||||||||||||||||||
|
This function has limited meaning under MacPerl. Disabling write per- |
||||||||||||||||||||
|
chmod(0444, 'foo'); |
# |
|||||||||||||||||||
|
chomp |
||||||||||||||||||||
|
chomp(VARIABLE) |
||||||||||||||||||||
|
Removes the line ending character (corresponding to the current value |
||||||||||||||||||||
|
Choose |
||||||||||||||||||||
|
MacPerl::Choose(DOMAIN, TYPE, PROMPT, CONSTRAINT, |
||||||||||||||||||||
|
Puts up a modal dialog, prompting the user to choose a network address. |
||||||||||||||||||||
|
|
||||||||||||||||||||
|
the dialog. CONSTRAINT |
||||||||||||||||||||
|
Choose |
||||||||||||||||||||
|
close |
||||||||||||||||||||
|
close(FILEHANDLE) |
||||||||||||||||||||
|
Closes the file associated with FILEHANDLE. |
||||||||||||||||||||
|
closedir |
||||||||||||||||||||
|
closedir(DIRHANDLE) |
||||||||||||||||||||
|
Closes the directory (folder) associated with DIRHANDLE. |
||||||||||||||||||||
|
continue |
||||||||||||||||||||
|
continue |
||||||||||||||||||||
|
Repetition control flow modifier. See: while. |
||||||||||||||||||||
|
dbmclose |
||||||||||||||||||||
|
dbmclose(HASH) |
||||||||||||||||||||
|
Breaks the binding between a DBM file and HASH. |
||||||||||||||||||||
|
dbmopen |
||||||||||||||||||||
|
dbmopen(HASH, DBNAME, MODE) |
||||||||||||||||||||
|
Binds one of various types of database (DB) file to HASH. DBNAME |
||||||||||||||||||||
|
defined |
||||||||||||||||||||
|
defined(EXPR) |
||||||||||||||||||||
|
Returns a Boolean value telling whether EXPR |
||||||||||||||||||||
|
|
|||||||||||||||||||||||
|
die |
|||||||||||||||||||||||
|
die(LIST) |
|||||||||||||||||||||||
|
Prints the value of LIST |
|||||||||||||||||||||||
|
Directory |
|||||||||||||||||||||||
|
`Directory` |
|||||||||||||||||||||||
|
Returns the current directory, followed by a newline. Same as `pwd`. |
|||||||||||||||||||||||
|
DoAppleScript |
|||||||||||||||||||||||
|
MacPerl::DoAppleScript(SCRIPT) |
|||||||||||||||||||||||
|
Executes an AppleScript script, SCRIPT. The AppleScript script code is |
|||||||||||||||||||||||
|
each |
|||||||||||||||||||||||
|
each(HASH) |
|||||||||||||||||||||||
|
In list context, returns a two element array consisting of the key and value |
|||||||||||||||||||||||
|
elsif |
|||||||||||||||||||||||
|
elsif (EXPR2) { ... } |
|||||||||||||||||||||||
|
Conditional control flow modifier. See: if |
|||||||||||||||||||||||
|
else |
|||||||||||||||||||||||
|
else { ... } |
|||||||||||||||||||||||
|
Conditional control flow modifier. See: if, unless |
|||||||||||||||||||||||
|
eof |
|||||||||||||||||||||||
|
eof(FILEHANDLE) |
|||||||||||||||||||||||
|
The eof |
|||||||||||||||||||||||
|
|
||||||||||||||
|
Unlike many Perl functions, eof |
||||||||||||||
|
FAccess |
||||||||||||||
|
MacPerl::FAccess(FILE, CMD, ARGS) |
||||||||||||||
|
This function is only available when using the MacPerl MPW tool; it is |
||||||||||||||
|
for |
||||||||||||||
|
for (EXPR; CONDITION; EXPR2) { ... } |
||||||||||||||
|
Repetition control flow modifier. Upon startup of a for |
||||||||||||||
|
foreach |
||||||||||||||
|
foreach SCALAR (LIST) { ... } |
||||||||||||||
|
Repetition control flow modifier. A foreach |
||||||||||||||
|
Note: |
||||||||||||||
|
|
|||||||||||||||||
|
getc |
|||||||||||||||||
|
getc(FILEHANDLE) |
|||||||||||||||||
|
Returns a string containing the next character (byte) read from FILE |
|||||||||||||||||
|
GetFileInfo |
|||||||||||||||||
|
MacPerl::GetFileInfo(FILE) |
|||||||||||||||||
|
In scalar context, returns the file type. In array context, returns (creator, |
|||||||||||||||||
|
glob |
|||||||||||||||||
|
glob(PATTERN) |
|||||||||||||||||
|
Expands the glob PATTERN |
|||||||||||||||||
|
goto |
|||||||||||||||||
|
goto LABEL |
|||||||||||||||||
|
A goto |
|||||||||||||||||
|
The last form, goto &SUB, substitutes a call to subroutine SUB |
|||||||||||||||||
|
hostname |
|||||||||||||||||
|
`hostname` |
|||||||||||||||||
|
Returns the name of the current Macintosh (if TCP/IP is running). |
|||||||||||||||||
|
|
|||||||||||||||||
|
if |
|||||||||||||||||
|
if (EXPR) |
|||||||||||||||||
|
Conditional control flow modifier. An if |
|||||||||||||||||
|
Any number of elsif |
|||||||||||||||||
|
An else |
|||||||||||||||||
|
index |
|||||||||||||||||
|
index(STRING, SUBSTRING, POSITION) |
|||||||||||||||||
|
Returns the position of the first occurrence of SUBSTRING |
|||||||||||||||||
|
keys |
|||||||||||||||||
|
keys(HASH) |
|||||||||||||||||
|
Returns an array consisting of all the keys of the named hash. See also: |
|||||||||||||||||
|
last |
|||||||||||||||||
|
last |
|||||||||||||||||
|
Control flow modifier, repetition. The last |
|||||||||||||||||
|
|
|||||||||||||||||||
|
length |
|||||||||||||||||||
|
length(EXPR) |
|||||||||||||||||||
|
Returns the length in characters of EXPR, or of $_ |
|||||||||||||||||||
|
LoadExternals |
|||||||||||||||||||
|
MacPerl::LoadExternals(LIBFILE) |
|||||||||||||||||||
|
Loads XCMD and XFCN extensions contained in file LIBFILE, which is |
|||||||||||||||||||
|
localtime |
|||||||||||||||||||
|
localtime(EXPR) |
|||||||||||||||||||
|
Converts a time as returned by time() |
|||||||||||||||||||
|
($sec, $min, $hour, $mday, $mon, $year, $wday, |
|||||||||||||||||||
|
All array elements are returned are numeric; $mon | |||||||||||||||||||