Introduction to the built-in special variables for Perl _perl

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

Special variable of regular expression

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.