$_ | The default input and pattern-searching space. |
$digit | Contains the subpattern from a successful parentheses pattern match. |
$. | The current input line number of last filehandle read. |
$! | Contains the current value of errno. |
$0 | The name of the file of the Perl script. |
@ARGV | The command line arguments issued when the script was started. |
@_ | The parameter array for subroutines. |
%ENV | This associative array contains your current environment. |
$_ 就是「這一個變數」,也是所有迴圈會用到的預設變數。
例如要讓perl 印出1到100:
for(1..100){
print $_;
}
$1..$9 這九個特殊變數就是比對的第n個結果
$! 會顯示錯誤的訊息
ex: open(FILE, "test.txt") or die $!;
結果:
沒有此一檔案或目錄 at ./oparse.pl line 32.
若寫成 open(FILE, "test.txt") or die "$!\n";
結果:
沒有此一檔案或目錄
沒有留言:
張貼留言