Thread Kleines Perl Problem
(10 answers)
Opened by Phipu at 2010-11-04 12:00
Das Script etwas schöner und schneller:
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 #!/user/bin/perl # Script zum entfernen von mehrfachen Zeilenumbrüchen. use strict; use warnings; my $file=shift(@ARGV); my $new='new.txt'; die "Usage: <script> <file>\n" unless($file); open(my $nw,'>', $new) or die("Error open $new ($!)\n"); open (my $fl,$file) or die("Error open $file ($!)\n"); while(my $line=<$fl>) { chomp($line); $line .= "\n" if($line); print $nw $line; } close $fl; close $nw; print "[*] opening file\n[*] removing newlines\n[*] write new file\n[*] done\n\n"; Last edited: 2010-11-04 13:57:04 +0100 (CET) |