Errin Larsen wrote:
> ok.  I'm not getting my question across clearly.  Let me try again.
> 
> I have a collection of data in a text file.  Here is an example:
> 
> ## foobar.txt ##
> one  two  three
> A     B     C
> yes  no    maybe
> 
> In a script (not on the command line) I want to be able to parse this
> data so that the first two elements in each line of the file end up in
> a hash as a key/value pair.

   my %h;
   while (<>) {
      my ($key, $value) = split;
      $h{$key} = $value;
   }

Or, if you want to get cutesy:

   my %h = map +(split)[0, 1], <>;

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to