Jose Malacara wrote:
>
> Hello. I was wondering if there was a way to open a file into a hash? I know
> this works for arrays, but was wondering if I this could be done for a hash
> also.
>
> I have a file called people.data, which contains two colums:
> jose 2
> karen 8
> jason 9
> tracey 1
>
> Can someone tell me what I am doing wrong here:
> =============================================
> #! /usr/bin/perl -w
use strict;
> open (INPUT, "<people.data");
open INPUT, 'people.data' or die "Cannot open 'people.data': $!";
> %people = <INPUT>;
my %people = map split, <INPUT>;
> close (INPUT);
>
> #%people = (
> # "jose" => '2',
> # "karen" => '8',
> # "jason" => '9',
> # "tracey" => '1'
> #);
>
> print "The value for jose is $people{jose}\n";
> =============================================
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]