HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
Perl language defines some special variable, usually $, @, or% as a prefix, for example: $ _.
Many special variables have a very long English name, operating system variable $! Can be written as $ OS_ERROR.
If you want to use the English name of a special variable in the program need to head to adduse English;.This English special variables descriptive.
The most commonly used special variable $ _, the variable contains the default input and pattern matching content. Examples are as follows:
#!/usr/bin/perl foreach ('Google','w3resource','Taobao') { print $_; print "\n"; }
The above program, the output is:
Google w3resource Taobao
The following example we do not use $ _ to output:
#!/usr/bin/perl foreach ('Google','w3resource','Taobao') { print; print "\n"; }
The above program, the output is:
Google w3resource Taobao
Example, the first output "Google", then output "w3resource", the final output "Taobao".
In the iteration loop, current loop of string in $ _ and then through the print output. Also print without specifying the output variable is used by default of $ _.
The following are a few states even without Perl will assume $ _ place:
According to the special nature of the use of variables can be divided into the following categories:
Special global scalar variable.
Special global array variable.
Hash special global variables.
Global special file handle.
Global special constant.
Regex special variables.
File handle special variables.
Following is a list of all the special scalar variable containing special characters and English in the form of variables:
$ _ | The default input and pattern matching content. |
$ ARG | |
$. | Previous read current line number of file handles |
$ NR | |
$ / | Input record separator, by default a newline character. As with undef this variable will read the end of the file. |
$ RS | |
$, | Output field separator |
$ OFS | |
$ \ | The output record separator |
$ ORS | |
$ " | The same $ variable, similar, but applied to the string enclosed in double quotes (or similar string interpolation) is inserted within the array of occasions and slice values. The default is a blank. |
$ LIST_SEPARATOR | |
$; | Delimiter used when a multidimensional array emulation. The default is "\ 034." |
$ SUBSCRIPT_SEPARATOR | |
$ ^ L | Sent to the output channels take the paper feed character. The default is "\ f". |
$ FORMAT_FORMFEED | |
$: | The current set of characters after which a string may be broken to fill continuation fields (starting with ^) in a format. Default is "\ n" ". |
$ FORMAT_LINE_BREAK_CHARACTERS | |
$ ^ A | Before printing variable data format for saving |
$ ACCUMULATOR | |
$ # | When you print digital default digital output format (obsolete). |
$ OFMT | |
$? | Return to the state of an external command |
$ CHILD_ERROR | |
$! | Numeric value of this variable is the value of errno, string value is the corresponding system error string |
$ OS_ERROR or $ ERRNO | |
$ @ | The eval command error message if it is empty, it means the last eval command completed successfully |
$ EVAL_ERROR | |
$$ | Perl script to run the current process ID |
$ PROCESS_ID or $ PID | |
$ < | The actual subscriber numbers of the current process |
$ REAL_USER_ID or $ UID | |
$> | Effective user number of the current process |
$ EFFECTIVE_USER_ID or $ EUID | |
$ ( | The current process actual number of user groups |
$ REAL_GROUP_ID or $ GID | |
$) | The current process's effective user group number |
$ EFFECTIVE_GROUP_ID or $ EGID | |
$ 0 | The file name contains the script being executed |
$ PROGRAM_NAME | |
$ [ | Index of the first element of the array of arrays, the default is 0. |
$] | Perl version number |
$ PERL_VERSION | |
$ ^ D | The value of the debug flag |
$ DEBUGGING | |
$ ^ E | In non-UNIX operating system environments extended error information |
$ EXTENDED_OS_ERROR | |
$ ^ F | Maximum file identifier value of said bundle |
$ SYSTEM_FD_MAX | |
$ ^ H | Activated by the compiler syntax checking status |
$ ^ I | Built-in control value of the editor |
$ INPLACE_EDIT | |
$ ^ M | Size spare memory pool |
$ ^ O | Operating system name |
$ OSNAME | |
$ ^ P | Specifies the current debugger internal variable value |
$ PERLDB | |
$ ^ T | Since the beginning of the new century, the pace of the seconds start to run out of time |
$ BASETIME | |
$ ^ W | The current value of the warning switch |
$ WARNING | |
$ ^ X | Perl binary executable code name |
$ EXECUTABLE_NAME | |
$ ARGV | Current file name read from the default file handle when |
@ARGV | To the script command line argument list |
@INC | When you import the module directory list to be searched |
@F | Enter the command line array |
% INC | Hash% INC contains all the files with a do or require statements contained Keyword is the file name, the value is the path of the file |
% ENV | Containing the current environment variable |
% SIG | Signal list and how to deal |
ARGV | Special file handle through the array variable @ARGV all file names |
STDERR | Standard output handle error |
STDIN | Standard input handle |
STDOUT | Standard output handle |
DATA | Special file handle reference any content __END__ flag in the file containing the contents of the script after. Or a reference to all of the content file contains __DATA__ flag after, as long as you have read in the same packet data, __ DATA__ there. |
_ (Underscore) | Special file handle cache files for information (fstat, stat and lstat). |
__END__ | The logical end of the script, the text after ignored. |
__FILE__ | Current file name |
__LINE__ | The current line number |
__PACKAGE__ | The current package name, the default package name is main. |
$ N | Containing the last pattern matching n th string |
$ & | Previous successful pattern matching string |
$ MATCH | |
$ ` | Last substring matching the success of the previous content |
$ PREMATCH | |
$ ' | Content last successful match after substring |
$ POSTMATCH | |
$ + | And the last regular expression search last parenthesis matching format. E.g: /Version: (.*)|Revision: (.*)/ && ($rev = $+); |
$ LAST_PAREN_MATCH |
$ | | If set to zero after each function call write or print, automatically calls the function fflush, written content will write the file |
$ OUTPUT_AUTOFLUSH | |
$% | The current output page number |
$ FORMAT_PAGE_NUMBER | |
$ = | The current page length. The default is 60. |
$ FORMAT_LINES_PER_PAGE | |
$ - | The current page number of lines remaining |
$ FORMAT_LINES_LEFT | |
$ ~ | The current name of the report output format. The default value is the name of the file handle. |
$ FORMAT_NAME | |
$ ^ | The current report output table name header format. The default value is with the suffix "_TOP" file handle name. |
$ FORMAT_TOP_NAME |