Thread Anzahl Zeilen in Textdatei ermitteln: (Wie mache ich das am schnellsten?) (34 answers)
Opened by Crian at 2004-04-21 11:58

sri
 2004-04-21 16:45
#81714 #81714
User since
2004-01-29
828 Artikel
BenutzerIn
[Homepage] [default_avatar]
[quote=Taulmarill,21.04.2004, 14:37]also nach dem was ich gebenchmarkt habe währe folgendes etwas schneller
Code: (dl )
1
2
while (<F>) {};
$c = $.;
[/quote]
Hier ist der Grund ;)

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
sri@odyssey:~$ perl -MO=Deparse -lpe '}{*_=*.}{' test.txt
BEGIN { $/ = "\n"; $\ = "\n"; }
LINE: while (defined($_ = <ARGV>)) {
chomp $_;
}
{
*_ = *.;
}
{
();
}
continue {
die "-p destination: $!\n" unless print $_;
}
-e syntax OK


sri@odyssey:~$ perl -MO=Deparse -pe '}{*_=*.}{' test.txt
BEGIN { $/ = "\n"; $\ = "\n"; }
LINE: while (defined($_ = <ARGV>)) {
();
}
{
*_=*.;
}
{
();
}
continue {
die "-p destination: $!\n" unless print $_;
}
-e syntax OK

sri@odyssey:~$ perl -MO=Deparse -e 'while (<>) {}; print $.' test.txt
while (defined($_ = <ARGV>)) {
();
}
print $.;
-e syntax OK


Soviel zum Thema Bytecode optimierung im Perl5 compiler... :-P\n\n

<!--EDIT|sri|1082552243-->

View full thread Anzahl Zeilen in Textdatei ermitteln: (Wie mache ich das am schnellsten?)