hello,
I am writing a flash card program with PERL, and I have two problems:
How do I read from a file in the format:
[][][] \t pronunciation
[][][] \t pronunciation
the [][][] basically represents any number of Unicode characters [in my case,
Chinese], and the pronunciation is in regular test.
and secondly, how do I ensure that Unicode will work on this program:
open(INPUT,"<","c:\\software\\alexcode\\AlexData.txt")
or die"Could not open input file for reading\n";
$count = 0;
my @prehasha = ();
while (<INPUT>)
{
chomp;
my ($values1, $values2) = split(/\t/,$_);
$prehasha[$count++] = $values1;
$prehasha[$count++] = $values2;
print "$values1 and $values2\n";
} #above this Mike wrote
print "after while statement @prehasha \n";
#now we have an array where the first element is the char and the seco
+nd element is the pinyin etc.
@char = ();
@pinyin = ();
while (@prehasha != 0)
{
$a = shift @prehasha;
$b = shift @prehasha;
push (@char, $a);
push (@pinyin, $b); #the array has officially been split!
}
print "@char : @pinyin\n";
keys %charpinyin = @char;
#values %charpinyin = @pinyin; #Mike approved 8:44 PM
$elnum = ($char)/2;
#now is where we assign random numbers to each pair in the hash!
$randomarray{$elnum-1} = ();
foreach (@randomarray) {
push (@random, int( rand($elnum-1) )-1)
}
#keys %randhash = 1..$elnum-1;
#values %randomhash = @randomarray;
#now we have two hashes, %charpinyin, and %randomarray, what I will do
+ now is sort the randomhash hash based on the random number, and use
+the key [0..elnum-1] to determine which pair to spit off on the scree
+n! clever, eh?
#the following few lines is ONLY a test#
while (($key, $value) = each(%charpinyin)) {
print "$key \t $value \n";
}
---------------------------------
Do you Yahoo!?
Win 1 of 4,000 free domain names from Yahoo! Enter now.