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
#!/usr/bin/perl use strict; use warnings; my $fix = 'abcdefg'; my $new = 'abcdgrf'; my %fhash; my $count; for (split //, $fix) { $count ++; $fhash{$_} = $count; } $count = 0; my $errcount; for my $char (split //, $new) { $count ++; if (!$fhash{$char}) { print "Zusaetzliches Zeichen: $char\n"; $errcount ++; } elsif ($fhash{$char} != $count) { print "Zeichen an Pos. $count statt an Pos. $fhash{$char}: $char\n"; $errcount ++; } } print "Anzahl Fehler: $errcount" if $errcount;
1 2 3 4 5 6 7 8
#!/usr/bin/env perl use 5.012; use warnings; my $fix = 'abcdefg'; my $new = 'abcdgrf'; say(($fix ^ $new) =~ tr/\0//c);