Jeff Borders wrote:
I need to dump a plain text file that has the format of:
key = value (ie. question <equal sign> answer)
into a hash. I'm writing a simple learning tool to help me learn some
basic korean terminology.
Would someone be kind enough to point me in the right direction.
-Jeff Borders
korean.txt:
One = Hana
Two = Dool
Three = Set
etc.
*********************************
#!/usr/bin/perl
%dictionary=("",,)
@answers=keys(%dictionary);
@questions=values(%dictionary);
open(DICT,"<korean.txt");
while($word = <DICT>) {
chomp($word);
# if ($word eq "=") {
# }
# print "$word\n";
}
close(DICT);
It sounds like you need something like this:
#!/usr/bin/perl
use warnings;
use strict;
open DICT, '<', 'korean.txt' or die "Cannot open 'korean.txt' $!";
my %dictionary = map /^([^=]+)=(.+)/, <DICT>;
close DICT;
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>