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

assigning array to hash

Thread Next
richard noel fell
April 26, 2002 06:52
assigning array to hash
Message ID:
Below is part of some code that reads from a file to an array and then
attempts to assign the array to a hash.  I get no compiling errors, but
%label_hash is empty. No doubt I am being stupid. Has anyone a
suggestion how to fill the hash variable?
Dick Fell

	open LABEL_FILE, "$current_directory/label_file" or die "Cannot open
label file:$!";
	my @label_array;
	while ( <LABEL_FILE>)

	print "label array=@label_array\n";
	my %label_hash=@label_array;
	print "label hash=%label_hash\n";

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About