in reply to Re: Again on "can't use string as hash as HASH ref while "strict refs" in use"
in thread Again on "can't use string as hash as HASH ref while "strict refs" in use"

Ok, so when you do this:

foreach my $name (@{ $heap->{cfg}->{devices} }) {

...you're actually looping over:

devices => [ 'ip', 'name', ]

array. In the next line, you're taking each one of those elements, say ip, and using it as the $name key in $heap->{cfg}->{device}->{$name} to get the value.

However, the value of $heap->{cfg}->{device}->{ip} is an actual IP address. You then proceed to attempt to access the localfile key from it, but of course the IP address is a string, so there's nothing perl can do (with use strict;) which is a very good thing (trust me).

With what I've seen so far, it doesn't look like you want to be doing any looping at all based on the structure you've got here... well, at least it looks like you don't want to loop over this specific structure.

Also, localfile is not present in your data at all. It appears it might fit into the default hash, but can't tell at this point.

You're going to have to post the entire script you're using in order to figure out at a higher level what's going on and is supposed to be going on.

-stevieb