perl 3.0 patch #33 patch #29, continued
[p5sagit/p5-mst-13.2.git] / perl.man.4
index 5f768aa..145284e 100644 (file)
@@ -1,7 +1,33 @@
 ''' Beginning of part 4
-''' $Header: perl.man.4,v 3.0.1.3 89/11/17 15:32:25 lwall Locked $
+''' $Header: perl_man.4,v 3.0.1.11 90/10/16 10:04:28 lwall Locked $
 '''
 ''' $Log:      perl.man.4,v $
+''' Revision 3.0.1.11  90/10/16  10:04:28  lwall
+''' patch29: added @###.## fields to format
+''' 
+''' Revision 3.0.1.10  90/08/09  04:47:35  lwall
+''' patch19: added require operator
+''' patch19: added numeric interpretation of $]
+''' 
+''' Revision 3.0.1.9  90/08/03  11:15:58  lwall
+''' patch19: Intermediate diffs for Randal
+''' 
+''' Revision 3.0.1.8  90/03/27  16:19:31  lwall
+''' patch16: MSDOS support
+''' 
+''' Revision 3.0.1.7  90/03/14  12:29:50  lwall
+''' patch15: man page falsely states that you can't subscript array values
+''' 
+''' Revision 3.0.1.6  90/03/12  16:54:04  lwall
+''' patch13: improved documentation of *name
+''' 
+''' Revision 3.0.1.5  90/02/28  18:01:52  lwall
+''' patch9: $0 is now always the command name
+''' 
+''' Revision 3.0.1.4  89/12/21  20:12:39  lwall
+''' patch7: documented that package'filehandle works as well as $package'variable
+''' patch7: documented which identifiers are always in package main
+''' 
 ''' Revision 3.0.1.3  89/11/17  15:32:25  lwall
 ''' patch5: fixed some manual typos and indent problems
 ''' patch5: clarified difference between $! and $@
@@ -204,7 +230,7 @@ of it rather than working with a local copy.
 In perl you can refer to all the objects of a particular name by prefixing
 the name with a star: *foo.
 When evaluated, it produces a scalar value that represents all the objects
-of that name.
+of that name, including any filehandle, format or subroutine.
 When assigned to within a local() operation, it causes the name mentioned
 to refer to whatever * value was assigned to it.
 Example:
@@ -236,6 +262,11 @@ The * mechanism will probably be more efficient in any case.
 Since a *name value contains unprintable binary data, if it is used as
 an argument in a print, or as a %s argument in a printf or sprintf, it
 then has the value '*name', just so it prints out pretty.
+.Sp
+Even if you don't want to modify an array, this mechanism is useful for
+passing multiple arrays in a single LIST, since normally the LIST mechanism
+will merge all the array values so that you can't extract out the
+individual arrays.
 .Sh "Regular Expressions"
 The patterns used in pattern matching are regular expressions such as
 those supplied in the Version 8 regexp routines.
@@ -259,7 +290,7 @@ The \e<digit> notation sometimes works outside the current pattern, but should
 not be relied upon.)
 $+ returns whatever the last bracket match matched.
 $& returns the entire matched string.
-($0 normally returns the same thing, but don't depend on it.)
+($0 used to return the same thing, but not any more.)
 $\` returns everything before the matched string.
 $\' returns everything after the matched string.
 Examples:
@@ -368,6 +399,8 @@ to do rudimentary multi-line text block filling.
 The length of the field is supplied by padding out the field
 with multiple <, >, or | characters to specify, respectively, left justification,
 right justification, or centering.
+As an alternate form of right justification,
+you may also use # characters (with an optional .) to specify a numeric field.
 If any of the values supplied for these fields contains a newline, only
 the text up to the newline is printed.
 The special field @* can be used for printing multi-line values.
@@ -479,14 +512,14 @@ Here is a sample client (untested):
        $SIG{'INT'} = 'dokill';
        sub dokill { kill 9,$child if $child; }
 
-       do 'sys/socket.h' || die "Can't do sys/socket.h: $@";
+       require 'sys/socket.ph';
 
        $sockaddr = 'S n a4 x8';
        chop($hostname = `hostname`);
 
        ($name, $aliases, $proto) = getprotobyname('tcp');
        ($name, $aliases, $port) = getservbyname($port, 'tcp')
-               unless $port =~ /^\ed+$/;;
+               unless $port =~ /^\ed+$/;
 .ie t \{\
        ($name, $aliases, $type, $len, $thisaddr) = gethostbyname($hostname);
 'br\}
@@ -525,13 +558,13 @@ And here's a server:
        ($port) = @ARGV;
        $port = 2345 unless $port;
 
-       do 'sys/socket.h' || die "Can't do sys/socket.h: $@";
+       require 'sys/socket.ph';
 
        $sockaddr = 'S n a4 x8';
 
        ($name, $aliases, $proto) = getprotobyname('tcp');
        ($name, $aliases, $port) = getservbyname($port, 'tcp')
-               unless $port =~ /^\ed+$/;;
+               unless $port =~ /^\ed+$/;
 
        $this = pack($sockaddr, &AF_INET, $port, "\e0\e0\e0\e0");
 
@@ -742,8 +775,6 @@ Default is 0.
 Contains the name of the file containing the
 .I perl
 script being executed.
-The value should be copied elsewhere before any pattern matching happens, which
-clobbers $0.
 (Mnemonic: same as sh and ksh.)
 .Ip $<digit> 8
 Contains the subpattern from the corresponding set of parentheses in the last
@@ -764,16 +795,21 @@ when subscripting and when evaluating the index() and substr() functions.
 The string printed out when you say \*(L"perl -v\*(R".
 It can be used to determine at the beginning of a script whether the perl
 interpreter executing the script is in the right range of versions.
+If used in a numeric context, returns the version + patchlevel / 1000.
 Example:
 .nf
 
-.ne 5
+.ne 8
        # see if getc is available
         ($version,$patchlevel) =
                 $] =~ /(\ed+\e.\ed+).*\enPatch level: (\ed+)/;
         print STDERR "(No filename completion available.)\en"
                 if $version * 1000 + $patchlevel < 2016;
 
+or, used numerically,
+
+       warn "No checksumming!\n" if $] < 3.019;
+
 .fi
 (Mnemonic: Is this version of perl in the right bracket?)
 .Ip $; 8 2
@@ -858,6 +894,8 @@ The current set of characters after which a string may be broken to
 fill continuation fields (starting with ^) in a format.
 Default is "\ \en-", to break on whitespace or hyphens.
 (Mnemonic: a \*(L"colon\*(R" in poetry is a part of a line.)
+.Ip $ARGV 8 3
+contains the name of the current file when reading from <>.
 .Ip @ARGV 8 3
 The array ARGV contains the command line arguments intended for the script.
 Note that $#ARGV is the generally number of arguments minus one, since
@@ -867,13 +905,21 @@ See $0 for the command name.
 The array INC contains the list of places to look for
 .I perl
 scripts to be
-evaluated by the \*(L"do EXPR\*(R" command.
+evaluated by the \*(L"do EXPR\*(R" command or the \*(L"require\*(r" command.
 It initially consists of the arguments to any
 .B \-I
 command line switches, followed
 by the default
 .I perl
-library, probably \*(L"/usr/local/lib/perl\*(R".
+library, probably \*(L"/usr/local/lib/perl\*(R",
+followed by \*(L".\*(R", to represent the current directory.
+.Ip %INC 8 3
+The associative array INC contains entries for each filename that has
+been included via \*(L"do\*(R" or \*(L"require\*(R".
+The key is the filename you specified, and the value is the location of
+the file actually found.
+The \*(L"require\*(R" command uses this array to determine whether
+a given file has already been included.
 .Ip $ENV{expr} 8 2
 The associative array ENV contains your current environment.
 Setting a value in ENV changes the environment for child processes.
@@ -909,12 +955,24 @@ declaration, you can switch namespaces.
 The scope of the package declaration is from the declaration itself to the end
 of the enclosing block (the same scope as the local() operator).
 Typically it would be the first declaration in a file to be included by
-the \*(L"do FILE\*(R" operator.
+the \*(L"require\*(R" operator.
 You can switch into a package in more than one place; it merely influences
 which symbol table is used by the compiler for the rest of that block.
-You can refer to variables in other packages by prefixing the name with
-the package name and a single quote.
+You can refer to variables and filehandles in other packages by prefixing
+the identifier with the package name and a single quote.
 If the package name is null, the \*(L"main\*(R" package as assumed.
+.PP
+Only identifiers starting with letters are stored in the packages symbol
+table.
+All other symbols are kept in package \*(L"main\*(R".
+In addition, the identifiers STDIN, STDOUT, STDERR, ARGV, ARGVOUT, ENV, INC
+and SIG are forced to be in package \*(L"main\*(R", even when used for
+other purposes than their built-in one.
+Note also that, if you have a package called \*(L"m\*(R", \*(L"s\*(R"
+or \*(L"y\*(R", the you can't use the qualified form of an identifier since it
+will be interpreted instead as a pattern match, a substitution
+or a translation.
+.PP
 Eval'ed strings are compiled in the package in which the eval was compiled
 in.
 (Assignments to $SIG{}, however, assume the signal handler specified is in the
@@ -978,7 +1036,7 @@ Here is dumpvar.pl from the perl library:
 
 .fi
 Note that, even though the subroutine is compiled in package dumpvar, the
-name of the subroutine is qualified so that it's name is inserted into package
+name of the subroutine is qualified so that its name is inserted into package
 \*(L"main\*(R".
 .Sh "Style"
 Each programmer will, of course, have his or her own preferences in regards
@@ -1068,16 +1126,26 @@ It will halt before the first executable statement and ask you for a
 command, such as:
 .Ip "h" 12 4
 Prints out a help message.
+.Ip "T" 12 4
+Stack trace.
 .Ip "s" 12 4
 Single step.
 Executes until it reaches the beginning of another statement.
+.Ip "n" 12 4
+Next.
+Executes over subroutine calls, until it reaches the beginning of the 
+next statement.
+.Ip "f" 12 4
+Finish.
+Executes statements until it has finished the current subroutine.
 .Ip "c" 12 4
 Continue.
 Executes until the next breakpoint is reached.
+.Ip "c line" 12 4
+Continue to the specified line.
+Inserts a one-time-only breakpoint at the specified line.
 .Ip "<CR>" 12 4
-Repeat last s or c.
-.Ip "n" 12 4
-Single step around subroutine call.
+Repeat last n or s.
 .Ip "l min+incr" 12 4
 List incr+1 lines starting at min.
 If min is omitted, starts where last listing left off.
@@ -1087,38 +1155,45 @@ List lines in the indicated range.
 .Ip "l line" 12 4
 List just the indicated line.
 .Ip "l" 12 4
-List incr+1 more lines after last printed line.
+List next window.
+.Ip "-" 12 4
+List previous window.
+.Ip "w line" 12 4
+List window around line.
 .Ip "l subname" 12 4
 List subroutine.
 If it's a long subroutine it just lists the beginning.
 Use \*(L"l\*(R" to list more.
+.Ip "/pattern/" 12 4
+Regular expression search forward for pattern; the final / is optional.
+.Ip "?pattern?" 12 4
+Regular expression search backward for pattern; the final ? is optional.
 .Ip "L" 12 4
 List lines that have breakpoints or actions.
+.Ip "S" 12 4
+Lists the names of all subroutines.
 .Ip "t" 12 4
 Toggle trace mode on or off.
-.Ip "b line" 12 4
+.Ip "b line condition" 12 4
 Set a breakpoint.
-If line is omitted, sets a breakpoint on the current line
+If line is omitted, sets a breakpoint on the 
 line that is about to be executed.
+If a condition is specified, it is evaluated each time the statement is
+reached and a breakpoint is taken only if the condition is true.
 Breakpoints may only be set on lines that begin an executable statement.
-.Ip "b subname" 12 4
+.Ip "b subname condition" 12 4
 Set breakpoint at first executable line of subroutine.
-.Ip "S" 12 4
-Lists the names of all subroutines.
 .Ip "d line" 12 4
 Delete breakpoint.
-If line is omitted, deletes the breakpoint on the current line
+If line is omitted, deletes the breakpoint on the 
 line that is about to be executed.
 .Ip "D" 12 4
 Delete all breakpoints.
-.Ip "A" 12 4
-Delete all line actions.
-.Ip "V package" 12 4
-List all variables in package.
-Default is main package.
 .Ip "a line command" 12 4
 Set an action for line.
 A multi-line command may be entered by backslashing the newlines.
+.Ip "A" 12 4
+Delete all line actions.
 .Ip "< command" 12 4
 Set an action to happen before every debugger prompt.
 A multi-line command may be entered by backslashing the newlines.
@@ -1126,6 +1201,9 @@ A multi-line command may be entered by backslashing the newlines.
 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.
+.Ip "V package" 12 4
+List all variables in package.
+Default is main package.
 .Ip "! number" 12 4
 Redo a debugging command.
 If number is omitted, redoes the previous command.
@@ -1147,15 +1225,16 @@ may be redirected to.
 .PP
 If you want to modify the debugger, copy perldb.pl from the perl library
 to your current directory and modify it as necessary.
+(You'll also have to put -I. on your command line.)
 You can do some customization by setting up a .perldb file which contains
 initialization code.
 For instance, you could make aliases like these:
 .nf
 
-    $DBalias{'len'} = 's/^len(.*)/p length(\e$1)/';
-    $DBalias{'stop'} = 's/^stop (at|in)/b/';
-    $DBalias{'.'} =
-      's/^./p "\e$DBsub(\e$DBline):\et\e$DBline[\e$DBline]"/';
+    $DB'alias{'len'} = 's/^len(.*)/p length($1)/';
+    $DB'alias{'stop'} = 's/^stop (at|in)/b/';
+    $DB'alias{'.'} =
+      's/^\e./p "\e$DB\e'sub(\e$DB\e'line):\et",\e$DB\e'line[\e$DB\e'line]/';
 
 .fi
 .Sh "Setuid Scripts"
@@ -1204,7 +1283,7 @@ For example:
 
 .ne 4
        system "echo $foo";             # Insecure
-       system "echo", $foo;    # Secure (doesn't use sh)
+       system "/bin/echo", $foo;       # Secure (doesn't use sh)
        system "echo $bar";             # Insecure
        system "echo $abc";             # Insecure until PATH set
 
@@ -1290,6 +1369,8 @@ before doing anything else, just to keep people honest:
 .fi
 .SH AUTHOR
 Larry Wall <lwall@jpl-devvax.Jpl.Nasa.Gov>
+.br
+MS-DOS port by Diomidis Spinellis <dds@cc.ic.ac.uk>
 .SH FILES
 /tmp/perl\-eXXXXXX     temporary file for
 .B \-e
@@ -1344,8 +1425,7 @@ operator has different arguments.
 .Ip * 4 2
 The current input line is normally in $_, not $0.
 It generally does not have the newline stripped.
-($0 is initially the name of the program executed, then the last matched
-string.)
+($0 is the name of the program executed.)
 .Ip * 4 2
 $<digit> does not refer to fields\*(--it refers to substrings matched by the last
 match pattern.
@@ -1393,7 +1473,7 @@ The following variables work differently
          OFS   \h'|2.5i'$,
          ORS   \h'|2.5i'$\e
          RLENGTH       \h'|2.5i'length($&)
-         RS    \h'|2.5i'$\/
+         RS    \h'|2.5i'$/
          RSTART        \h'|2.5i'length($\`)
          SUBSEP        \h'|2.5i'$;
 
@@ -1434,8 +1514,6 @@ ARGV must be capitalized.
 The \*(L"system\*(R" calls link, unlink, rename, etc. return nonzero for success, not 0.
 .Ip * 4 2
 Signal handlers deal with signal names, not numbers.
-.Ip * 4 2
-You can't subscript array values, only arrays (no $x = (1,2,3)[2];).
 .PP
 Seasoned
 .I sed