in reply to Cannot read hash variable from file as global...
Dropping the "my" makes this variable "global" in its package, which I assume to be the "main" package for lack of another package declaration, so to access the %Log_rooms on another package, you have to access it as %main::Log_rooms.
%Log_rooms = (one => 1, two => 2, three => 3); # we are in the "main" +package here package Cybro_Item; print join "\n", keys %main::Log_rooms;
PS: There are better ways of dealing with config-files. Personally I am very fond of the family of YAML modules.
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Cannot read hash variable from file as global...
by Anonymous Monk on Mar 27, 2009 at 10:59 UTC | |
by drench (Beadle) on Mar 27, 2009 at 15:47 UTC |