Thread bestimmte Zeile aus txt Datei einlesen (10 answers)
Opened by mari at 2005-01-07 16:39

renee
 2005-01-07 17:39
#50644 #50644
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
nein Crian hat mit $. schon recht (siehe perldoc perlvar):
Quote
$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 (via readline() or "<>"), or
when tell() or seek() 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, but not
when an open filehandle is reopened without an
intervening close(). For more details, see "I/O
Operators" in perlop. Because "<>" never does an
explicit close, line numbers increase across ARGV
files (but see examples in "eof" in perlfunc).

You can also use "HANDLE->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 cur-
rent line number.)
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/

View full thread bestimmte Zeile aus txt Datei einlesen