in reply to hash problem
First, I think you might have an error in the code you submitted. I assume that
should be$names{$refnum} = $str;
Second, the reason the code is dying is because on the last line, $names{$number} does not exist.$names{$ref} = $str;
It might be a good idea to take a look at what $names is actually holding after the loop. A good way to see that is to use Data::Dumper
This will help you track down the problem.#!/usr/bin/perl use Data::Dumper; %names; { open(name, "<data/gly.txt"); while(<name>) { ($ref, $str) = split /\|/; $names{$ref} = $str; } } print Dumper(%names);
davidj
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: hash problem
by Anonymous Monk on Jun 08, 2005 at 09:08 UTC | |
by davidj (Priest) on Jun 08, 2005 at 09:11 UTC | |
by Anonymous Monk on Jun 08, 2005 at 09:14 UTC |
In Section
Seekers of Perl Wisdom