⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 perlvar.pod

📁 ARM上的如果你对底层感兴趣
💻 POD
📖 第 1 页 / 共 3 页
字号:

it really means

    $foo{join($;, $a, $b, $c)}

But don't put

    @foo{$a,$b,$c}	# a slice--note the @

which means

    ($foo{$a},$foo{$b},$foo{$c})

Default is "\034", the same as SUBSEP in B<awk>.  Note that if your
keys contain binary data there might not be any safe value for "C<$;>".
(Mnemonic: comma (the syntactic subscript separator) is a
semi-semicolon.  Yeah, I know, it's pretty lame, but "C<$,>" is already
taken for something more important.)

Consider using "real" multidimensional arrays.

=item $OFMT

=item $#

The output format for printed numbers.  This variable is a half-hearted
attempt to emulate B<awk>'s OFMT variable.  There are times, however,
when B<awk> and Perl have differing notions of what is in fact
numeric.  The initial value is %.I<n>g, where I<n> is the value
of the macro DBL_DIG from your system's F<float.h>.  This is different from
B<awk>'s default OFMT setting of %.6g, so you need to set "C<$#>"
explicitly to get B<awk>'s value.  (Mnemonic: # is the number sign.)

Use of "C<$#>" is deprecated.

=item format_page_number HANDLE EXPR

=item $FORMAT_PAGE_NUMBER

=item $%

The current page number of the currently selected output channel.
(Mnemonic: % is page number in B<nroff>.)

=item format_lines_per_page HANDLE EXPR

=item $FORMAT_LINES_PER_PAGE

=item $=

The current page length (printable lines) of the currently selected
output channel.  Default is 60.  (Mnemonic: = has horizontal lines.)

=item format_lines_left HANDLE EXPR

=item $FORMAT_LINES_LEFT

=item $-

The number of lines left on the page of the currently selected output
channel.  (Mnemonic: lines_on_page - lines_printed.)

=item format_name HANDLE EXPR

=item $FORMAT_NAME

=item $~

The name of the current report format for the currently selected output
channel.  Default is name of the filehandle.  (Mnemonic: brother to
"C<$^>".)

=item format_top_name HANDLE EXPR

=item $FORMAT_TOP_NAME

=item $^

The name of the current top-of-page format for the currently selected
output channel.  Default is name of the filehandle with _TOP
appended.  (Mnemonic: points to top of page.)

=item format_line_break_characters HANDLE EXPR

=item $FORMAT_LINE_BREAK_CHARACTERS

=item $:

The current set of characters after which a string may be broken to
fill continuation fields (starting with ^) in a format.  Default is
S<" \n-">, to break on whitespace or hyphens.  (Mnemonic: a "colon" in
poetry is a part of a line.)

=item format_formfeed HANDLE EXPR

=item $FORMAT_FORMFEED

=item $^L

What formats output to perform a form feed.  Default is \f.

=item $ACCUMULATOR

=item $^A

The current value of the write() accumulator for format() lines.  A format
contains formline() commands that put their result into C<$^A>.  After
calling its format, write() prints out the contents of C<$^A> and empties.
So you never actually see the contents of C<$^A> unless you call
formline() yourself and then look at it.  See L<perlform> and
L<perlfunc/formline()>.

=item $CHILD_ERROR

=item $?

The status returned by the last pipe close, backtick (C<``>) command,
or system() operator.  Note that this is the status word returned by the
wait() system call (or else is made up to look like it).  Thus, the exit
value of the subprocess is actually (C<$? E<gt>E<gt> 8>), and C<$? & 127>
gives which signal, if any, the process died from, and C<$? & 128> reports
whether there was a core dump.  (Mnemonic: similar to B<sh> and B<ksh>.)

Additionally, if the C<h_errno> variable is supported in C, its value
is returned via $? if any of the C<gethost*()> functions fail.

Note that if you have installed a signal handler for C<SIGCHLD>, the
value of C<$?> will usually be wrong outside that handler.

Inside an C<END> subroutine C<$?> contains the value that is going to be
given to C<exit()>.  You can modify C<$?> in an C<END> subroutine to
change the exit status of the script.

Under VMS, the pragma C<use vmsish 'status'> makes C<$?> reflect the
actual VMS exit status, instead of the default emulation of POSIX
status.

Also see L<Error Indicators>.

=item $OS_ERROR

=item $ERRNO

=item $!

If used in a numeric context, yields the current value of errno, with
all the usual caveats.  (This means that you shouldn't depend on the
value of C<$!> to be anything in particular unless you've gotten a
specific error return indicating a system error.)  If used in a string
context, yields the corresponding system error string.  You can assign
to C<$!> to set I<errno> if, for instance, you want C<"$!"> to return the
string for error I<n>, or you want to set the exit value for the die()
operator.  (Mnemonic: What just went bang?)

Also see L<Error Indicators>.

=item $EXTENDED_OS_ERROR

=item $^E

Error information specific to the current operating system.  At
the moment, this differs from C<$!> under only VMS, OS/2, and Win32
(and for MacPerl).  On all other platforms, C<$^E> is always just
the same as C<$!>.

Under VMS, C<$^E> provides the VMS status value from the last
system error.  This is more specific information about the last
system error than that provided by C<$!>.  This is particularly
important when C<$!> is set to B<EVMSERR>.

Under OS/2, C<$^E> is set to the error code of the last call to
OS/2 API either via CRT, or directly from perl.

Under Win32, C<$^E> always returns the last error information
reported by the Win32 call C<GetLastError()> which describes
the last error from within the Win32 API.  Most Win32-specific
code will report errors via C<$^E>.  ANSI C and UNIX-like calls
set C<errno> and so most portable Perl code will report errors
via C<$!>. 

Caveats mentioned in the description of C<$!> generally apply to
C<$^E>, also.  (Mnemonic: Extra error explanation.)

Also see L<Error Indicators>.

=item $EVAL_ERROR

=item $@

The Perl syntax error message from the last eval() command.  If null, the
last eval() parsed and executed correctly (although the operations you
invoked may have failed in the normal fashion).  (Mnemonic: Where was
the syntax error "at"?)

Note that warning messages are not collected in this variable.  You can,
however, set up a routine to process warnings by setting C<$SIG{__WARN__}>
as described below.

Also see L<Error Indicators>.

=item $PROCESS_ID

=item $PID

=item $$

The process number of the Perl running this script.  (Mnemonic: same
as shells.)

=item $REAL_USER_ID

=item $UID

=item $<

The real uid of this process.  (Mnemonic: it's the uid you came I<FROM>,
if you're running setuid.)

=item $EFFECTIVE_USER_ID

=item $EUID

=item $>

The effective uid of this process.  Example:

    $< = $>;		# set real to effective uid
    ($<,$>) = ($>,$<);	# swap real and effective uid

(Mnemonic: it's the uid you went I<TO>, if you're running setuid.)
Note: "C<$E<lt>>" and "C<$E<gt>>" can be swapped only on machines
supporting setreuid().

=item $REAL_GROUP_ID

=item $GID

=item $(

The real gid of this process.  If you are on a machine that supports
membership in multiple groups simultaneously, gives a space separated
list of groups you are in.  The first number is the one returned by
getgid(), and the subsequent ones by getgroups(), one of which may be
the same as the first number.

However, a value assigned to "C<$(>" must be a single number used to
set the real gid.  So the value given by "C<$(>" should I<not> be assigned
back to "C<$(>" without being forced numeric, such as by adding zero.

(Mnemonic: parentheses are used to I<GROUP> things.  The real gid is the
group you I<LEFT>, if you're running setgid.)

=item $EFFECTIVE_GROUP_ID

=item $EGID

=item $)

The effective gid of this process.  If you are on a machine that
supports membership in multiple groups simultaneously, gives a space
separated list of groups you are in.  The first number is the one
returned by getegid(), and the subsequent ones by getgroups(), one of
which may be the same as the first number.

Similarly, a value assigned to "C<$)>" must also be a space-separated
list of numbers.  The first number is used to set the effective gid, and
the rest (if any) are passed to setgroups().  To get the effect of an
empty list for setgroups(), just repeat the new effective gid; that is,
to force an effective gid of 5 and an effectively empty setgroups()
list, say C< $) = "5 5" >.

(Mnemonic: parentheses are used to I<GROUP> things.  The effective gid
is the group that's I<RIGHT> for you, if you're running setgid.)

Note: "C<$E<lt>>", "C<$E<gt>>", "C<$(>" and "C<$)>" can be set only on
machines that support the corresponding I<set[re][ug]id()> routine.  "C<$(>"
and "C<$)>" can be swapped only on machines supporting setregid().

=item $PROGRAM_NAME

=item $0

Contains the name of the file containing the Perl script being
executed.  On some operating systems
assigning to "C<$0>" modifies the argument area that the ps(1)
program sees.  This is more useful as a way of indicating the
current program state than it is for hiding the program you're running.
(Mnemonic: same as B<sh> and B<ksh>.)

=item $[

The index of the first element in an array, and of the first character
in a substring.  Default is 0, but you could set it to 1 to make
Perl behave more like B<awk> (or Fortran) when subscripting and when
evaluating the index() and substr() functions.  (Mnemonic: [ begins
subscripts.)

As of Perl 5, assignment to "C<$[>" is treated as a compiler directive,
and cannot influence the behavior of any other file.  Its use is
discouraged.

=item $PERL_VERSION

=item $]

The version + patchlevel / 1000 of the Perl interpreter.  This variable
can be used to determine whether the Perl interpreter executing a
script is in the right range of versions.  (Mnemonic: Is this version
of perl in the right bracket?)  Example:

    warn "No checksumming!\n" if $] < 3.019;

See also the documentation of C<use VERSION> and C<require VERSION>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -