Your data structure has no localfile entry, but you try to access it:
my $CFG = $heap->{cfg}->{device}->{$name}->{localfile};
What do you expect to happen here?
The path through your data structure ends at 192.168.0.1, which is what Perl told you. There is no localfile below that. You need to go back and talk to the people writing the XML structure what should happen here. Also, using XML::Simple is often problematic, as it usually brings problem if a structure only repeats once or repeats multiple times.