Thread Optimierung eines Programms (35 answers)
Opened by Jan at 2014-12-19 09:34

rosti
 2014-12-19 11:05
#178808 #178808
User since
2011-03-19
3196 Artikel
BenutzerIn
[Homepage]
user image
Code (perl): (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
use strict;
use warnings;
use IO::File;

my @files = qw(adressen.txt);
my $fh_in  = IO::File->new;

# Ergebnis Datei
my $fh_out = IO::File->new;
$fh_out->open('result.txt', O_CREAT|O_RDWR) or die "IO-Error: $!";


foreach my $file(@files){
    $fh_in->open($file, 'r') or die $!;
    my $fstline = <$fh_in>; # first line skip

    my $offset = $fh_in->tell; # brauchen wir das?, Nö
    # Rest der Datei von $fh_in nach $fh_out
    while( read( $fh_in, my $buffer, 1024 ) ){
        $fh_out->print($buffer);
    }

    $fh_in->close;
}

$fh_out->close;


PS: Die Pfade da sind noch reinzuschmacken :)
Last edited: 2014-12-19 11:08:06 +0100 (CET)

View full thread Optimierung eines Programms