i get an error saying i cant use an undefined value as an array reference on the line with the push statement.
Then the hash wasn’t correctly read-in from the data file. Have you fixed the format of the data as kevbot showed? Without further details (see The SSCCE), it’s impossible to know where the problem lies.
<Update>
Add the error handling code shown at the end of the do documentation to determine whether the do statement (1) failed to read the file, (2) read the file but failed to parse (compile) it, or (3) successfully read and parsed the file. Then print out the contents of %hash to see exactly what data was read in.
</Update>
Also because my function will be called multiple times will the global %hash variable be overwritten?
Yes, of course, each time the subroutine is called the do $fileName; statement will overwrite %hash with the data in the indicated file.
Hope that helps,
| [reply] [Watch: Dir/Any] [d/l] [select] |