in reply to Adding value to hash
Looking at your code, I do not see an error. $temp_hash{$temp_name} is a valid key/value pair of a properly declared hash...
From my own mistakes in the past, here's a suggestion: check the output of your SQL query. It looks like your $sql_result is not defined and so $temp_hash becomes a scalar, which is not defined. Insert a
That would help clarify what's going on with the code...print "sql_result=($sql_result), temp_name=($temp_name), temp_id=($tem +p_id)\n";
Alternatively, assign $sql_result a value directly for testing and verify the behaviour of the program...
UPDATE: tests have shown that in the situation I've described, perl does not complain... it only does if %temp_hash is really not defined. Therefore, I tend to agree with Fletch: it might be the scope...
--------------------------------
An idea is not responsible for the people who believe in it...
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Adding value to hash
by wazoox (Prior) on Jul 25, 2005 at 14:09 UTC | |
Re^2: Adding value to hash
by reasonablekeith (Deacon) on Jul 25, 2005 at 13:20 UTC |
In Section
Seekers of Perl Wisdom