Movatterモバイル変換


[0]ホーム

URL:


variables /$.
(source,CPAN)
You are viewing the version of this documentation from Perl 5.28.0.View the latest version
#HANDLE->input_line_number( EXPR )
#$INPUT_LINE_NUMBER
#$NR
#$.

Current line number for the last filehandle accessed.

Each filehandle in Perl counts the number of lines that have been read from it. (Depending on the value of$/, Perl's idea of what constitutes a line may not match yours.) When a line is read from a filehandle (viareadline() or<>), or whentell() orseek() is called on it,$. becomes an alias to the line counter for that filehandle.

You can adjust the counter by assigning to$., but this will not actually move the seek pointer.Localizing$. will not localize the filehandle's line count. Instead, it will localize perl's notion of which filehandle$. is currently aliased to.

$. is reset when the filehandle is closed, butnot when an open filehandle is reopened without an interveningclose(). For more details, see"I/O Operators" in perlop. Because<> never does an explicit close, line numbers increase acrossARGV files (but see examples in"eof" in perlfunc).

You can also useHANDLE->input_line_number(EXPR) to access the line counter for a given filehandle without having to worry about which handle you last accessed.

Mnemonic: many programs use "." to mean the current line number.

Perldoc Browser is maintained by Dan Book (DBOOK). Please contact him via theGitHub issue tracker oremail regarding any issues with the site itself, search, or rendering of documentation.

The Perl documentation is maintained by the Perl 5 Porters in the development of Perl. Please contact them via thePerl issue tracker, themailing list, orIRC to report any issues with the contents or format of the documentation.


[8]ページ先頭

©2009-2026 Movatter.jp