Thread [S]Möglichkeit um Textdateien aufzuteilen (5 answers)
Opened by pr0ViL at 2008-04-13 15:22

pq
 2008-04-13 15:48
#108299 #108299
User since
2003-08-04
12208 Artikel
Admin1
[Homepage]
user image
ungetestet:
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
for my $file (@list_of_files) {

    open my $read, '<', $file or die $!;
    my $count = 0;
    my $new_name = "$file$count";
    open my $write, '>', $new_name or die $!;
    while (my $line = <$read>) {
        print $write $line;
        if ($. % 25 == 0 and not eof $read) {
            $count++;
            close $write;
            $new_name = "$file$count";
            open $write, '>', $new_name or die $!;
        }
    }
}
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 [S]Möglichkeit um Textdateien aufzuteilen