develooper Front page | perl.beginners | Postings from April 2002

Re: assigning array to hash

Thread Previous | Thread Next
From:
drieux
Date:
April 26, 2002 11:02
Subject:
Re: assigning array to hash
Message ID:
A5F6F1D2-593F-11D6-A8F7-0030654D3CAE@wetware.com

On Friday, April 26, 2002, at 10:28 , richard noel fell wrote:

> Drieux -
> 	Thanks. I altered the LABEL_FILE data format as you suggested and all
> works just fine now.
> Dick

you could of course generate the file in the form

key val
key1 val1

and then do the simpler shot to the hash

	my %hash = ();	# ok - i never trust anyone to initialize it right

	while(<FH>) {
		chomp;
		/^(\S*)\s+(\S*)/;
		$hash{ $1 } = $2;
	}

and just skip going to the @array to begin with....

ciao
drieux

---



Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About