Karl Kaufman wrote:
Help,please...!, I'm dead in the water trying to understand why I'm unable to reference hash entries in what *I consider* to be a fairly straightforward manner. Any help/pointer is appreciated.

The hash entries *must* exist because I can reference and print them using a literal key (or within a foreach loop using the internal variable):

print $device{server1} . "x\n"; # Works fine

However, I CANNOT reference them using a separate variable:

print $device{$_} . "x\n"; # Is failing miserably!!

What's my defect?!?

Thanks in advance...!

Karl K.


EXAMPLE OUTPUT ---
$device{server1}: x1x
$_: xserver1x Use of uninitialized value at ./devicesWIP line 198. $device{$_}: xx


PORTION OF EXAMPLE CODE (please let me know if more is needed) ---

print '$device{server1}: x' . $device{server1} . "x\n"; print '$_: x' . $_ . "x\n"; print '$device{$_}: x' . $device{$_} . "x\n";

It looks like $_ is being unset/reset before you index into the hash, hence the "Use of uninitialized value at..." warning. If you post more code around line 198 (specifically before) it might help to uncover what is unsetting $_. This is why some perler's would rather write more verbose code, than let Perl provide excessive amounts of rope ;-)...

http://danconia.org


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to