Introduction to special built-in variables of perl

Source: Internet
Author: User
Tags perl interpreter perl script

I. Special variables of Regular Expressions

1. $ n: contains the nth substring of the last pattern match.
2. $ &: String matched in the previous successful mode
3. $ ': Content Before the successful substring
4. $ ': content after the child string that was matched successfully before
5. $ +: the string that was previously matched using the brackets pattern.

Ii. file handle special Variables

1. $ |: if it is set to zero, the fflush function is automatically called every time the function write or print is called, and the written content is written back to the file.
2. $ %: current output page number
3. $ =: current length of each page
4. $-: number of remaining lines on the current page
5. $ ~ : Name of the current report output format. The default value is the file handle name.
6. $ ^: name of the current report output Header Format. The default value is the file handle name with the suffix "_ TOP.

Iii. Global Special Variables

1. $ _ and $ ARG: Default Input and mode matching content. If you do not specify to receive input variables or strings that match the execution mode
2. $. and $ NR: current row number of the file handle read before
3. $/and $ RS: the input record delimiter. The default Delimiter is a new line character. If you use the undef variable, it will be read to the end of the file.
4. $, $ OFS: Output domain separator.
5. $ \ and $ ORS: Output record Separator
6. $: The line break character. The default value is "\ n -".
7. $! : The numeric value of this variable is the value of errno, and the string value is the corresponding system error string
8. $ @: error message of the command eval. If it is null, the last eval command is successfully executed.
9. $: Process Number of the current Perl script program
10. $ <: actual user number of the current process
11. $>: valid user number of the current process
12. $ (: actual group user number of the current process
13. $): valid group user number of the current process
14. $ [: subscript of the first element of the array. The default value is 0.
15. $]: Perl version
16. $ ARGV: When "<>" is used to read a file, the current file name is saved.

4. Global Special array Variables

1. @ ARGV: Save the command line parameters.
2. @ INC: Save and find the directory of the Perl Program
3. @ _: In a subroutine, this array variable contains the parameters passed to the subroutine.
4.% INC: Hash List % INC contains all files contained in the do or require statement. The keyword is the file name and the value is the file path.
5.% ENV: contains the current environment variable

5. Global special file handle

1. ARGV: traverses the special file handle of 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

$-Number of printable lines on the current page, part of the Perl format system
$! Returns the error code or string based on the context content.
$ "List Separator
$ # Default digital output format when printing numbers
$ Perl interpreter process ID
$ % Current page number of the current output channel
$ & String matching the previous format
$ (Group ID of the current process
$) Valid group ID of the current process
$ * Setting 1 indicates processing the multiline format. It is replaced by the/s and/m modifiers.
$, Delimiter of the current output field
$. Current row number of the last Read File
$/Delimiter of the current input record. The default value is a new line.
$: Character setting. Subsequent strings are separated to fill continuous fields.
$; Delimiter used to simulate multi-dimensional arrays.
$? Returns the status of the last external command.
$ @ Error message returned by the Perl interpreter from the eval statement
$ [Index number of the first element in the array
$ Delimiter of the current output record
$] Sub-version number of the Perl interpreter
$ ^ Name of the top page output format of the current channel
$ ^ A variables used to save formatted data before printing
$ ^ D debug flag value
$ ^ E Operating System Extension error message in non-UNIX environment
$ ^ F maximum file bundle operator Value
$ ^ H check status of the syntax activated by the compiler
$ ^ I built-in control editor Value
$ ^ L form feed sent to the output channel
$ ^ M backup memory pool size
$ ^ O operating system name
$ ^ P specifies the internal variable of the current debugging Value
$ ^ R result of the last evaluation of the regular expression Block
$ ^ S current interpreter status
$ ^ T start from the new century, and the start time of the notebook is calculated in seconds.
$ ^ W current value of the warning Switch
$ ^ X Perl binary executable code name
$ _ Default input/output and format matching space
$ | Controls the buffer of the currently selected output file handle
$ ~ Name of the current report format
$ 'String before matching information in the previous format
$ 'String after matching information in the previous format
$ + The last parenthesis matching the previous regular expression search format
$ <Real id of the user currently executing the interpreter
$ Contains the matching result in parentheses corresponding to the previous Regular Expression
$ = Number of printable rows on the current page
$> Valid user ID of the current process
$0 contains the file name of the script being executed
$ ARGV current file name when reading from the default file handle
% ENV Environment Variable list
% INC list of files contained through do or require
% SIG signal list and Processing Method
@ _ List of parameters passed to the subroutine
@ ARGV: List of command line parameters passed to the script
@ INC: List of directories to be searched during module Import
$-[0] and $ + [0] represent the starting and ending positions of the currently matched 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.