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

assigning array to hash

Thread Next
From:
richard noel fell
Date:
April 26, 2002 06:52
Subject:
assigning array to hash
Message ID:
3CC95F94.5A68B633@rcn.com
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?
Thanks,
Dick Fell


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

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

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