Thread Mit while durch file loopen und aktuelle line veraendern
(27 answers)
Opened by Student87 at 2012-11-13 10:40 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 #!/usr/bin/perl use strict; use warnings; my $file='test_values'; open (my $fh, '+>', $file) or die "ERR $file $!"; my @lines=<$fh>; seek($fh,0,0); # zum Anfang der Datei for my $line (@lines) { chomp($line); my @line_array = split (/\t/, $line); if ($line_array[1] == 45) { print "success\n"; } else { print $fh "$line\n"; } } close ($fh); Last edited: 2012-11-13 11:00:03 +0100 (CET) |