Thread zwei Dateien Vergleichen
(11 answers)
Opened by commander at 2012-08-13 13:38
grob getestet:
Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 my %results; open my $fh1, "<", "file1" or die $!; while (my $line = <$fh1>) { chomp $line; $results{ $line } = 1; } open my $fh2, "<", "file2" or die $!; while (my $line = <$fh2>) { chomp $line; my $part = $line; $part =~ s/\..*//; unless ($results{ $part }) { say $line; } } 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: Wie frage ich & perlintro brian's Leitfaden für jedes Perl-Problem |