Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
etc. I want to load these into a hash, with with entries as keys. I currently do it like this:natural number: a non-negative integer counting number: a positive integer rational number: a real that can be expressed as a fraction
This works. But isn't there a simpler, shorter, cooler way to do this? Maybe a one-liner?%words = (); while (<>) { chop; ($word, $def) = split /: */; $words{$word} = $def; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Loading a textfile into a hash
by kabel (Chaplain) on Nov 14, 2002 at 10:23 UTC | |
|
Re: Loading a textfile into a hash
by Monky Python (Scribe) on Nov 14, 2002 at 10:38 UTC |