in reply to Putting text file into a hash

I think I understand your problem, and here is what I would do: open(FILEHANDLE, "<hash.dat") or die("boo! error"); while(<FILEHANDLE>){ print $_; %hash = split(" ", <FILEHANDLE>); } update: and by the way, sorry for the bad format of the post..... will read up now

Replies are listed 'Best First'.
Re^2: Putting text file into a hash
by toolic (Bishop) on Oct 17, 2008 at 17:41 UTC
    Your code does not work. After reading up on posting (Writeup Formatting Tips), try to run your code.

    When I add use warnings; use strict;, there are warnings which give you a clue as to why it might be failing:

    use strict; use warnings; use Data::Dumper; my %hash; open(FILEHANDLE, "<hash.dat") or die("boo! error"); while(<FILEHANDLE>) { # print $_; %hash = split(" ", <FILEHANDLE>); } print Dumper(\%hash); __END__ Odd number of elements in hash assignment at .., <FILEHANDLE> line 2. $VAR1 = {};