in reply to creating a hash from a text file.

Your data file seems to contain several items per line, but you're only looking for one. Maybe try
while ($line =~ /(\d+)\s+(\w+)/g) { $hash{$1} = $2; }

In your inner loop.

Update: added /g, as noted by AnomalousMonk.

Perl 6 - links to (nearly) everything that is Perl 6.

Replies are listed 'Best First'.
Re^2: creating a hash from a text file.
by AnomalousMonk (Archbishop) on Jul 27, 2010 at 07:45 UTC

    Loop condition
        while ($line =~ /(\d+)\s+(\w+)/) { ... }
    will produce infinite loop. Use /g regex modifier to extract all pairs:
        while ($line =~ /(\d+)\s+(\w+)/g) { ... }