1 2 3
my ($filename) = shift @ARGV; open (my $fh, '<', $filename) or die "Datei '$filename' nicht gefunden";
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 37 38
use strict; use warnings; use File::Compare; my %exclude; my $file1 = 'default_sysdumpdev_150319.txt'; my $file2 = 'd100spuptl25e0_sysdumpdev.txt'; my $compare = compare('d100spuptl25e0_sysdumpdev.txt', 'default_sysdumpdev_150319.txt'); open my $file, '<', 'default_sysdumpdev_150319.txt' or die $!; while (<$file>) { chomp; $exclude{$_}++; } my $txtdatei = 'compare.txt'; open my $txtfh, '>', $txtdatei or die $!; open $file, '<', 'd100spuptl25e0_sysdumpdev.txt' or die $!; while (<$file>) { chomp; if($compare == 1){ #print $txtfh "False! the files are not equal \n"; print $txtfh "FALSE! $_\n" unless $exclude{$_}; } elsif($compare == 0){ print $txtfh "True! the Files are equal \n"; } } close $txtfh;
Guest Henridie Eingabedatein müssen als Parameter beim Aufruf des Scriptes mitübergeben werden.
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 37 38 39
use strict; use warnings; use File::Compare; my %exclude; my $file1 = $ARGV[0] || die 'No file 1'; my $file2 = $ARGV[1] || die 'No file 2'; my $txtdatei = $ARGV[3] || 'No file 3'; my $compare = compare($file2, $file1); open my $file, '<', $file1 or die $!; while (<$file>) { chomp; $exclude{$_}++; } open my $txtfh, '>', $txtdatei or die $!; open $file, '<', $file2 or die $!; while (<$file>) { chomp; if($compare == 1){ #print $txtfh "False! the files are not equal \n"; print $txtfh "FALSE! $_\n" unless $exclude{$_}; } elsif($compare == 0){ print $txtfh "True! the Files are equal \n"; } } close $txtfh;