師匠の散歩

Perlで遊ぼう

perlvar一覧

師匠の注釈

特殊変数の英語表記を使うにはEnglishモジュールを使う。ここでは表示を残すが、使用確認は実施せず、今後も基本的には使わないことにする。

注釈は、参考文献を元に、師匠が理解した内容を掲載する。英語の文章を読めば書いてある意味はわかるので、実際に確かめていないものは空白に、確かめたが結局理解できなかったものは「理解不能」と表示した。

よく使うものは背景を変更した。

最新のPerlで廃止になっているものは背景を変更した。

なお、変更したくなるような特殊変数($"など)の扱いが結構めんどくさい。初期化できればいいんだが、初期化できるテクニックは、まだWebで見つけられていない。予防措置として、必要最低限の変更に留め、CGIの最後でデフォルト値に戻すなどをしたほうがいいかもしれない。

Engllishvarexplanations師匠の注釈
$ARG$_The default input and pattern-searching space.入力やパターンマッチの対象
@ARG@_Within a subroutine the array @_ contains the parameters passed to that subroutine.サブルーチンへの引数
 $a $bSpecial package variables when using sort(), see sort.ソートの並び替えで使う
一般変数で$a,$bは使わないようにする
 $1 $2 $nContains the subpattern from the corresponding set of capturing parentheses from the last successful pattern match, not counting patterns matched in nested blocks that have been exited already.パターンマッチした順番の対象
一般変数で$nは使わないようにする
$MATCH$&The string matched by the last successful pattern match .パターンマッチ:対象文字列
$PREMATCH$`The string preceding whatever was matched by the last successful pattern match パターンマッチ:前の部分文字列
$POSTMATCH$'The string following whatever was matched by the last successful pattern match .パターンマッチ:後の部分文字列
$LAST_PAREN_MATCH$+The text matched by the last bracket of the last successful search pattern. 最新perlでは廃止
$LAST_SUBMATCH_RESULT$^NThe text matched by the used group most-recently closed (i.e. the group with the rightmost closing parenthesis) of the last successful search pattern. 
@LAST_MATCH_END@+This array holds the offsets of the ends of the last successful submatches in the currently active dynamic scope. たぶん$+と同様廃止のはず
%LAST_PAREN_MATCH%+Similar to @+ , the %+ hash allows access to the named capture buffers, should they exist, in the last successful match in the currently active dynamic scope.たぶん$+と同様廃止のはず
$INPUT_LINE_NUMBER
$NR
$.Current line number for the last filehandle accessed.理解不能
$INPUT_RECORD_SEPARATOR
$RS
$/The input record separator, newline by default. @_のデータ間区切り文字、デフォルト:改行
$OUTPUT_AUTOFLUSH$|If set to nonzero, forces a flush right away and after every write or print on the currently selected output channel. Default is 0
$OUTPUT_FIELD_SEPARATOR
$OFS
$,The output field separator for the print operator. Default is undef.$,="<>";print "1","2";とすると、1<>2と表示される
初期値は無("")
$OUTPUT_RECORD_SEPARATOR
$ORS
$\The output record separator for the print operator. Default is undef.printの行末文字
初期値は無("")。お勧めしない
$LIST_SEPARATOR$"This is like $, except that it applies to array and slice values interpolated into a double-quoted string. Default is a space.配列printの区切り文字。
初期値は半角スペース
$SUBSCRIPT_SEPARATOR
$SUBSEP
$;The subscript separator for multidimensional array emulation. Default is "\034"理解不能
アスキーコード034は " である
$FORMAT_PAGE_NUMBER$%The current page number of the currently selected output channel. 
$FORMAT_LINES_PER_PAGE$=The current page length (printable lines) of the currently selected output channel. Default is 60. Used with formats.  
$FORMAT_LINES_LEFT$- The number of lines left on the page of the currently selected output channel. 
@LAST_MATCH_START@-$-[0] is the offset of the start of the last successful match. $-[n] is the offset of the start of the substring matched by n-th subpattern, or undef if the subpattern did not match. 
 %-Similar to %+ , this variable allows access to the named capture buffers in the last successful match in the currently active dynamic scope.  
$FORMAT_NAME$~The name of the current report format for the currently selected output channel. Default is the name of the filehandle.フォーマット名
eg STDOUT
$FORMAT_TOP_NAME$^The name of the current top-of-page format for the currently selected output channel. Default is the name of the filehandle with _TOP appended.ヘッダのフォーマット名
eg STDOUT_TOP
$FORMAT_LINE_ BREAK_CHARACTERS$:The current set of characters after which a string may be broken to fill continuation fields (starting with ^) in a format. Default is " \n-", to break on whitespace or hyphens. 
$FORMAT_FORMFEED$^LWhat formats output as a form feed. Default is \f. 
$ACCUMULATOR$^AThe current value of the write() accumulator for format() lines. 
$CHILD_ERROR$?The status returned by the last pipe close, backtick (`` ) command, successful call to wait() or waitpid(), or from the system() operator. コマンドのステータス値=エラー内容
$OS_ERROR
$ERRNO
$!If used numerically, yields the current value of the C errno variable, or in other words, if a system or library call fails, it sets this variable.エラーコード
"%OS_ERROR
%ERRNO"
@!Each element of %! has a true value only if $! is set to that value.  
$EXTENDED_OS_ERROR$^EError information specific to the current operating system.  
$EVAL_ERROR$@The Perl syntax error message from the last eval() operator.Syntaxエラー
$PROCESS_ID
$PID
$$The process number of the Perl running this script.  
$REAL_USER_ID
$UID
$<The real uid of this process. 
$EFFECTIVE_USER_ID
$EUID
$>The effective uid of this process. 
$REAL_GROUP_ID
$GID
$(The real gid of this process. 
$EFFECTIVE_GROUP_ID
$EGID
$) The effective gid of this process. 
$PROGRAM_NAME$0 Contains the name of the program being executed.走っている Perlのファイルの名称
通常は ***.cgiのファイル
 $[ The index of the first element in an array, and of the first character in a substring. Default is 0, 
$PERL_VERSION$] The version + patchlevel / 1000 of the Perl interpreter.Perl のバージョン番号
eg 5.010001
$COMPILING$^CThe current value of the flag associated with the -c switch.  
$DEBUGGING$^DThe current value of the debugging flags. 
$SYSTEM_FD_MAX$^F The maximum system file descriptor, ordinarily 2. 
 $^HThis variable contains compile-time hints for the Perl interpreter.理解不能
 %^HThe %^H hash provides the same scoping semantic as $^H. 
$INPLACE_EDIT$^IThe current value of the inplace-edit extension. Use undef to disable inplace editing. 
 $^MPerl can use the contents of $^M as an emergency memory pool after die()ing. 
$OSNAME$^OThe name of the operating system under which this copy of Perl was built, as determined during the configuration process.オペレーティングシステム名
eg. freebsd
$PERLDB$^PThe internal variable for debugging support. 
$LAST_REGEXP_ CODE_RESULT$^RThe result of evaluation of the last successful (?{ code }) regular expression assertion (see perlre). 
$EXCEPTIONS_ BEING_CAUGHT$^SCurrent state of the interpreter. 
$BASETIME$^TThe time at which the program began running, in seconds since the epoch (beginning of 1970).エポック(1970年1月1日午前0時)からの秒数
$PERL_VERSION$^VThe revision, version, and subversion of the Perl interpreter, represented as a version object.This variable first appeared in perl 5.6.0バージョン名
eg. v5.10.1
$WARNING$^WThe current value of the warning switch, initially true if -w was used, false otherwise, but directly modifiable. 
$EXECUTABLE_NAME$^XThe name used to execute the current copy of Perl, from C's argv[0] or (where supported) /proc/self/exe.サーバーのPerlのパス
eg. /usr/local/bin/perl
 ARGV The special filehandle that iterates over command-line filenames in @ARGV . Usually written as the null filehandle in the angle operator <> 
 $ARGVcontains the name of the current file when reading from <>.<>でファイルを読み取るときの対象
open(IN,"read.txt") || &error("Can't open \$ARGV") と書くことが出来る。
Englishモジュール不要
 @ARGVThe array @ARGV contains the command-line arguments intended for the script. 
 ARGVOUTThe special filehandle that points to the currently open output file when doing edit-in-place processing with -i. 
 @FThe array @F contains the fields of each line read in when autosplit mode is turned on. 
 @INCThe array @INC contains the list of places that the do EXPR , require, or use constructs look for their library files.Perlライブラリ検索ディレクトリ
 %INCThe hash %INC contains entries for each filename included via the do, require, or use operators.do や require によってインクルードされたライブラリファイル名
 %ENVThe hash %ENV contains your current environment.環境変数の値
 &SIGThe hash %SIG contains signal handlers for signals. 
 $#Format printed numbers. was removed in Perl 5.10 出力時の数値形式。通常は"\%20g"
Perl5.10で廃止
 $*Multiline matching was removed in Perl 5.10. 複数行検索
Perl5.10で廃止
 __PACKAGE_ これが書かれた「ファイル」のパッケージ名。元のperlのパッケージは、暗黙で「main」と決まっている(みたいだ)。
eg main
 __FILE__ これが書かれた「ファイル」の名称。モジュールに書かれた場合は、モジュールのファイル名になる。
eg maplib.pm
 _LINE__ これが書かれた「ファイル」の物理行番号
eg 2010
 _END__ ファイル中でこれ以下をプログラムから切り離す。参照しないサブルーチンや製作途中のコードがあるが、ひとつのファイルに記述しておきたい場合に便利。
なくても文法間違いがなければ問題ない
_
戻る
2010-2011 grandmaster all rights reserved. 最終更新:2011/1/25