#!/usr/bin/perl ######################## # $Id: flashcard 113 2004-03-26 15:11:10Z steve $ ######################## # $Log$ # Revision 1.3 2004/03/26 15:11:10 steve # faster, better, stronger # # Revision 1.2 2003/01/16 00:23:11 steve # engine should work better now. added GPL info # ######################## use strict; use utf8; use Getopt::Std; getopts("abh"); usage() unless @ARGV; my @langs; my @review; foreach my $file ( @ARGV ){ open FLASH, "<$file" or die "cannot open $file for reading: $!"; foreach my $line (){ $line =~ s/#.+$//; if( my ($worda, $wordb) = $line =~ /^(.+?)\t+(.+?)$/ ){ push @langs, [$worda, $wordb]; } } } while(1){ my $langsel = int rand 2; my $word = int rand @langs; my $doreview = ((int rand 5) == 1) if @review; my $reviewnum = rand @review; my $word_pair = $langs[$word]; $word_pair = $review[$reviewnum] if $doreview; print $word_pair->[$langsel], "\n"; my $foo = ; print $word_pair->[($langsel + 1) % 2], "\n"; my $bar = ; $foo = $bar if $bar =~ /\S/; if( $foo =~ /n/i ){ push @review, $word_pair; }elsif( $doreview && $foo =~ /y/i ){ splice @review, $reviewnum, 1; }elsif( $foo =~ /p/i ){ use Data::Dumper; print Dumper \@review; $foo = ; } print "\e[2J"; } sub usage{ die < This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA USAGE }