in reply to Re: Accessing variables in an external hash without eval
in thread Accessing variables in an external hash without eval

Thank you but the solution didnt work for me, I still get an uninitialized variable for my @hashData. However i was able to get your code to load in $loadedFile.

  • Comment on Re^2: Accessing variables in an external hash without eval

Replies are listed 'Best First'.
Re^3: Accessing variables in an external hash without eval
by Laurent_R (Canon) on May 17, 2017 at 06:10 UTC
    If it did not work for you (but you don't explain i which respect it did not work) and worked for huck, then it is likely there's something wrong in the code you did not show, perhaps in the hash initialization you replaced with pseudo-code.
Re^3: Accessing variables in an external hash without eval
by marinersk (Priest) on May 18, 2017 at 02:13 UTC

    I still get an uninitialized variable for my @hashData.

    Then it seems obvious that you're not loading a value with this line:

    my @hashData  = $hash{Scope}{model};

    Side note: This should probably read more like:

    my @hashData  = @$hash{Scope}{model};

    Never assume there is data where you expect it to be when it is coming from an outside source. Check it first. For example:

    my @hashData = (); if (!defined $hash{Scope}{model}) { print "Scope and model missing!\n"; } else { @hashData = @$hash{Scope}{model}; }

    ...or something of that ilk.