ldoc perlreftut" and "perldoc
perlref"
> and "perldoc perllol".
>
> -Original Message-
> From: Jamie Risk [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, January 29, 2003 3:03 PM
> To: [EMAIL PROTECTED]
> Subject: Re: creating hash from name/value
Jamie Risk wrote:
>
> Okay, it's 5:25pm and I started programming PERL shortly after downloading
> the 5.8.0 tarballs at 2:30pm.
> I'd like to create a hash from a text file that has name/value pairs, one
> per line. So far, I'm only capable of reading it in as a list - this PERL
> stuff really se
al Message-
From: Jamie Risk [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 29, 2003 3:03 PM
To: [EMAIL PROTECTED]
Subject: Re: creating hash from name/value found in file.
Thanks, Timothy, I almost had it before I decided to look back at the list.
My only concern was the creation of data sp
Thanks, Timothy, I almost had it before I decided to look back at the list.
My only concern was the creation of data space for each new key, I guess
it's a non issue. ALTHOUGH, if I have repetitions of keys, code below would
obliterate previous key data, would it not? I guess I'm looking at a hash
> -Original Message-
> From: Jamie Risk [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 30, 2003 9:32 AM
> To: [EMAIL PROTECTED]
> Subject: creating hash from name/value found in file.
>
>
> Okay, it's 5:25pm and I started programming PERL shortly
> after downloading
> the 5.8.0 t
Why not something like this?
my %hash;
while(){
chomp $_;#remove the newline
my($key,$value) = split(/,/,$_); #split by commas or whatever
$hash{$key} = $value;#assign the value here
}
foreach(sort keys %hash){
print "$key => $value\n";
}
-Origin