how do i utilize an external hashtable?
hi if i have a file called table.hash looking like this: { 'HEADLINE' = 'Carcinoma in Situ', 'SUBHEADLINE' = ' the precursor cell for testicular germ cell cancer in adolescents and young adults ', 'BODYTEXT' = ' This site provides information on research, diagnosis and management of early forms of testicular cancer and is directed to physicians, researchers and patients. The site has been developed by members of the CIS Testis Cancer Research Group led by Professor Niels E. Skakkebæk, MD at the Department of Growth Reproduction in collaboration with the Danish Cancer Society, Copenhagen, Denmark. ' } how do i access the hashtable with a key and return the appropriate value? martin -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how do i utilize an external hashtable?
On Mon, Jan 28, 2002 at 06:13:26PM +0100, Martin A. Hansen wrote: :hi : :if i have a file called table.hash looking like this: : [ snipped hash data ] : :how do i access the hashtable with a key and return the appropriate :value? Hey martin, in order to use the file that you showed us, use the following code as an example: my $hashfile = 'file'; # open the file and slurp it all up into $hashdata open HF, $hashfile or die $!; my $hashdata = do { local $/; HF }; # perldoc perlvar for $/ close HF; # eval the $hashdata as a hash reference.. turns this into # 'my $hash = { ... }; my $hash = eval $hashdata; # perldoc -f eval die $@ if $@;# perldoc perlvar for $@ # now just use the hash reference print $hash-{one}\n; Enjoy! Casey West -- Considering the flames and intolerance, shouldn't USENET be spelled ABUSENET? -- Michael Meissner -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]