Basic code (assuming the file you're reading consists *ONLY* of word/link pairs on a single line ... I'd suggest separating them with something other than a pipe, too, but whatever.)
# assuming the link data file is open
my $keywords;
while (<LINKDATA>) {
# regex matches (everything to the left of the pipe), puts
# it in $1, then (everything to the right of the pipe)
# and puts that in $2
/([^|]+)\|(.*)/;
$keywords{$1} = $2;
}
This should be reasonably efficient in terms of speed and not so bad on memory if your list of words isn't too large.
HTH,
Philosophy can be made out of anything. Or less -- Jerry A. Fodor |