Raffael, Raffael Schmid schrieb:
Ich möchte gerne einen Skript-Performance-Test von verschiedenen Sprachen durchführen. Selbst kann ich PHP beisteuern, aber bash,ruby,perl,python,... sind willkommen:-)
Der Auftrag lautet wie folgt: das beigefügte Textfile enthält eine Liste. Diese Liste soll ausgewertet werden. Für jede Zeile soll ein File in /tmp/ erstellt und wieder gelöscht werden. Das File sollte die Zeilen in folgender Form enthalten: <Spaltentitel 1> : <Feld 1> <Spaltentitel 2> : <Feld 2>
... eine Variante in perl ... ------------------------------- #!/usr/bin/perl -w use File::Temp qw(tempfile); # open the list open(FH, "<test-db.txt") || die "error opening test-db.txt"; # read header line and remove LF chomp(my $line = <FH>); my @header = split('\t', $line); # and read all the fields while(chomp($_ = <FH>)) { # read the fields my @fields = split('\t'); # create a tempfile my $fh = tempfile(); # and write the content as requested foreach my $i (0..$#header) { print $fh "$header[$i]: $fields[$i]\n"; } # delete the file close($fh); } close(FH); -------------------------------- Gruss, Peter.