Thread array daten in file schreiben: geschrieben wird leider nur die 1 zeile (15 answers)
Opened by Rambo at 2005-03-09 00:21

pq
 2005-03-09 23:20
#52457 #52457
User since
2003-08-04
12209 Artikel
Admin1
[Homepage]
user image
oder so, das ist effizienter:
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
use strict;
use warnings;
my $cli = 'file.txt';
open (FILE,"<$cli") or die $!;
while (my $cli_str = <FILE>) {
 nextline($cli_str);
}
closefh();
close FILE;
{
 my $fh;
 sub nextline {
   my (@cli_str) = @_;
   print @cli_str;
   unless ($fh && defined fileno $fh) {
     open $fh, ">data.txt" or die $!;
   }
   print $fh @cli_str;
 }
 sub closefh {
   close $fh;
   undef $fh;
 }
}
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 array daten in file schreiben: geschrieben wird leider nur die 1 zeile