Thread Zeile x _schnell_ aus riesigem file raussuchen ? (19 answers)
Opened by Student87 at 2013-02-19 12:50

pq
 2013-02-20 14:24
#165909 #165909
User since
2003-08-04
12208 Artikel
Admin1
[Homepage]
user image
das mit read hast du falsch verstanden.
perldoc -f read:

Quote
read FILEHANDLE,SCALAR,LENGTH,OFFSET
read FILEHANDLE,SCALAR,LENGTH
[...]
An OFFSET may be specified to place the read data at some place in the string other
than the beginning
. A negative OFFSET specifies placement at that many characters
counting backwards from the end of the string. A positive OFFSET greater than the
length of SCALAR results in the string being padded to the required size with "\0"
bytes before the result of the read is appended.


beispiel:
Code: (dl )
1
2
3
4
5
6
7
$ perl -wE'
my $buffer = "abcdefghijklmno";
read STDIN, $buffer, 3, 5;
say $buffer;
'
1234567890
abcde123

man sieht, der eingelesene string wird an die stelle 5 geschrieben. "abcde" bleibt stehen.
aber ist auch nicht tragisch, man kann ja einfach seek() vorher benutzen.
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. -- Damian Conway in "Perl Best Practices"
lesen: Wiki:Wie frage ich & perlintro Wiki:brian's Leitfaden für jedes Perl-Problem

View full thread Zeile x _schnell_ aus riesigem file raussuchen ?