Perl Built-in Special Variables Summary _ Basic Tutorial

Source: Internet
Author: User
Tags character set eval numeric value perl interpreter stdin perl script

[File handle]

$| If Non-zero, force clear buffer after write or print operation on the currently selected file
$% the current page number of the currently selected file handle
$= the current page length of the currently selected file handle
$-the remaining length of the page for the currently selected file handle
$~ the name of the report format for the currently selected file handle
$^ the current header format name for the currently selected file handle

[Global variables]

$_ default input and mode search space
$@ an error message from the previous eval, do, or require function
$/Enter the separator for the record, which defaults to a newline character (similar to RS in awk)
$\ the input record separator for the print function. Line breaks are not printed unless $\= "\ n" is set
$# the digital output format printed using the print function (similar to the OMFT in awk)
$? The last closed pipe, the command in the inverted quotation mark, and the return status of the system function
$! Returns an error number or error string based on the context content
$$ Perl Program Process ID running this script
The default value for $* is 0. If 1, there is a multiple-row match in the string, and 0 means only matching in a single line
$, the output field separator of the print function. Typically, the delimiters are not printed in a comma-delimited string unless the $,= "" is set.
$ "is similar to $, but it is provided in double quotes with a print array, with the default value of a space
$ Perl Foot Name
$[the index to the first character of an array or substring, with a default value of 0
$] Print out the first part of the string when using the PERL-V command to obtain version information
$; The subscript separator for multidimensional arrays. Default is \034 (similar to awk subsep)
$. The current input line number of the previous file handle is read; You must close the previous file handle to reset the line number on the next file handle
$< the actual UID of the process
Valid UID for $> process
$ (actual GID of the process
$) Effective GID for the process
$: The character set, breaks the string that follows, and fills in a continuous line (starting at ^) in some form. By default, it is separated by a white-space character, newline character, or colon.
$^a Formline and write-operated accumulators
$^c returns TRUE if Perl uses the-C option to run in only compiled mode
$^d Use the-D switch to open the Perl debug tag
$^e operating system related error messages
$^f the maximum number of file descriptors passed to the subroutine, typically 2
$^h the current state of the grammar check
$^i the current value of the extension in-situ editing when using the-I switch
$^l paper feed character, used in format
$^M Emergency Memory Pool
$^o Operating system name
$^p internal Perl Debug Tag
$^s the state of the PERL interpreter
$^t script Execution time. For-A, C, and-m test operators, which can be set to any numeric value returned by time, to perform a file test related to the current times
$^v Perl Version
Current setting of the $^W warning switch
$^x the full path name of the Perl call
_ Underline, which is responsible for testing the special identifier of a file when declaring a file
ARGV a special file handle array for row parameter loops
$ARGV a variable with the current file name when reading from <ARGV>
@ARGV an array that contains command line arguments
DATA a special file handle variable, which is responsible for referencing the content following the _END_ flag
@F an array of input rows is automatically split when the-a switch is used
@INC an array containing the file name path, require and do functions to search for the file name path to be imported from
%inc an associative array with a filename path, require and do functions will search for the path of the file name to be imported from. Where the key is the file name and the value is the file path location
%env an associative array containing the current environment variable
Default symbol for @EXPORT export
@EXPORT_OK symbols that are exported based on user requests
%export_tags is used in exporter.pm to uniformly name a collection of symbols
%sig an associative array to set up a signal-processing routine
STDERR Special file handle for standard error content
STDIN a special file handle for standard input
STDOUT Special file handles for standard output content
$-[0] and $+[0] represent the starting and terminating positions of the current matching regular expression in the matched string

[local variable in block]

The $1..$9 contains a child memory pattern with a corresponding set of parentheses. (equivalent to \1..\9)
$& last string matching the pattern (equivalent to the SED editor)
$ ' previous leading string for the item that matches the pattern
$ ' string after the last item that matches the pattern
$+ the last pattern that matches the search pattern
@_ a list of parameters to a subroutine

Attached: Another summary

One, regular expression special variable:
1, $n: The nth substring containing the last pattern match
2, $&: Previous successful pattern matching string
3, $ ': previous match successful substring before
4, $ ': After the substring of the previous match succeeded
5, $+: The previous use of parentheses pattern matching the string.

Second, the file handle special variables:
1, $| : If set to zero, the function fflush is called automatically after each call to the function write or print, and the written content is written back to the file
2, $%: Current output page number
3, $=: The current length of each page
4, $-: The number of rows remaining on the current page
5, $~: The name of the current report output format. The default value is the file handle name.
6, $^: The name of the current report output header format. The default value is a file handle name with the suffix "_top".

Third, global special variables:
1, $_ and $arg: Default input and pattern matching content. If you do not specify a variable to receive input or a string that performs a pattern match
2, $. and $nr: The current line number of the previous read file handle
3, $/and $rs: Enter the record separator, the default is the new line character. If you use the undef variable, you will read the end of the file
4, $, $ofs: output domain separator.
5, $\ and $ors: Output record separator
6, $:: Break the character, the default is "n" three characters
7, $! : The numeric value of this variable is the errno value, and the string value is the corresponding system error string
8. $@: The error message for the eval command. If empty, the last eval command executed successfully
9. $$: Process number running the current Perl script program
10, $<: The actual user number of the current process
11. $>: Valid user number for current process
12, $ (: Actual group user number of the current process)
13, $): Valid group user number for current process
14, $[: Array array of the first element of the subscript, default is 0
15, $]:P version number of Erl
16. $ARGV: Save the current file name when using "< >" to read the file

Four, global special array variables:
1, @ARGV: Save command Line parameters
2, @INC: Save directory to find Perl programs
3, @_: In the subroutine, this array variable contains the parameters passed to the subroutine
4.%inc: Hash list%inc contains all the files contained in do or require statements. The keyword is the file name, and the value is the path to the file.
5,%env: Contains the current environment variables
Five, global special file handle
1. ARGV: A special file handle that traverses all file names in the array variable @argv
2, STDERR: standard error output handle
3. STDIN: Standard input handle
4, STDOUT: standard output handle

Perl Built-in variables:
$-the number of lines that the current page can print, part of the Perl format system
$! Returns an error number or error string based on the context content
$ "List separator
$# the default digital output format when printing numbers
$$ The process ID of the Perl interpreter
$% Current page number of the current output channel
$& a string that matches the previous format
$ (Group ID of the current process
$) Valid group ID for the current process
$* Set 1 to handle multiple-line formatting. Now replace it with the/s and/M modifiers.
$, Current output field separator
$. Current input line number of the last read file
$/current input record delimiter, default is new row
$: Character settings, subsequent strings will be separated to fill contiguous fields.
$; The delimiter to use when simulating a multidimensional array.
$? Returns the status of the previous external command
$@ The Perl interpreter returns an error message from the eval statement
The index number of the first element in the $[array
$ separator for current output record
$] Sub version number of the Perl interpreter
$^ the top page output format name of the current channel
$^a variables used to save formatted data before printing
$^d the value of the debug flag
$^e operating system extended error messages in non-UNIX environments
$^f Maximum file Bundle Descriptor value
$^h the compiler-activated syntax check state
$^i the value of the built-in control editor
$^l a paper-feed break sent to the output channel
$^m the size of the standby memory pool
$^o Operating system name
$^P specifies the internal variable for the current debug value
$^r the last evaluation result of a regular expression block
$^s Current Interpreter State
$^t from the beginning of the new century, the pace of the beginning of the time calculated in seconds
The current value of the $^W warning switch
$^x perl binary Executable code name
$_ default input/output and format matching space
$| Controls the buffering of the currently selected output file handle
$~ the name of the current report format
$ ' string before matching information in the previous format
$ ' string after matching information in the previous format
$+ the last bracket that matches the last regular expression search format
$< The true ID of the user who is currently executing the interpreter
$ contains the parentheses result corresponding to the last matched regular expression
$= the number of lines that the current page can print
$> A valid user ID for the current process
$ contains the filename of the script being executed
$ARGV the current file name when read from the default file handle
%ENV Environment Variables List
%inc a list of files contained by do or require
%sig signal list and how to handle it
@_ a list of parameters to a subroutine
@ARGV a list of command line arguments passed to the script
@INC List of directories to search for when importing a module
$-[0] and $+[0] represent the starting and terminating positions of the current matching regular expression in the matched string.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.