#!/usr/bin/perl use strict; use warnings; open (LESEN, "Vokabeln.txt")||die "Die Datei konnte nicht gefunden werden"; my $vokabeln=; close (LESEN); my @vokabeln_array = split (/:+/, $vokabeln); open (LESEN, "Loesung.txt")||die "Die Datei konnte nicht gefunden werden"; my $loesung=; close (LESEN); my @loesung_array = split (/:+/, $loesung); my$anzahl_loesung= $#loesung_array; my$anzahl_vokabeln= $#vokabeln_array; my @alle_versuche; my @alle_vokabeln; my $durchgaenge=0; while ($durchgaenge<($anzahl_loesung+1)) { my $zahl=0+rand($anzahl_vokabeln); print"Translate the word $vokabeln_array[$zahl]\n"; my $eingabe = ; chomp $eingabe; push @alle_versuche, $eingabe; push @alle_vokabeln, $vokabeln_array[$zahl]; if ($eingabe eq $loesung_array[$zahl]) { print"The translation is correct!\n"; $durchgaenge++; } else { print"The translation is incorrect\n"; print"Do you want to save the incorrect word and answer?\n"; print"(1)Yes (2)No\n"; my $antwort=; chomp$antwort; if($antwort eq 1){ open(SCHREIB,">nichtgekonnte.txt"); print SCHREIB ">>Wrong:\n"; print SCHREIB join "\n", @alle_vokabeln; print SCHREIB "\n\n"; print SCHREIB ">>Answer:\n"; print SCHREIB join "\n", @alle_versuche; close(SCHREIB); $durchgaenge++; } else{ $durchgaenge++; } } }