Thread Stings vergleichen
(11 answers)
Opened by Rennofen at 2017-10-12 22:23
chomp war der Fehler, ich hatte keine eindeutigen Zeilenumbrüche.
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 27 28 29 30 31 32 33 34 35 36 #!/bin/perl use strict; use warnings; my $filename = '808.nc'; open(my $fh, '<:encoding(UTF-8)', $filename) or die "Could not open file '$filename' $!"; my $g="G"; my $f="F"; while (my $row = <$fh>) { $row =~ s/\r?\n$//; my @words = split / /, $row; foreach (@words){ my $Word=$_; my $char=substr($_, 0, 1); if ($char eq "N"){ print "$Word" } elsif ($char eq "G"){ if($Word ne $g){ $g=$Word; print " $Word" } } elsif ($char eq "F"){ if($Word ne $f){ $f=$Word; print " $Word" } } else {print " $Word"} } print "\n"; } macht jetzt was es soll. Danke! |