in reply to Re^2: How can I access package variables in a dynamic way
in thread How can I access package variables in a dynamic way

I can't change the Person package right now. I know it's wrong but I'm stuck with it.

If that really, really, really is the case, then here's enough rope to shoot yourself in the foot. This uses a trick to make $Person::addresses an arrayref whose elements are aliases to the original variables, so that you can modify elements of the array to modify the original variables. Consider this monkey-patching the Person package.

$Person::addresses = sub{\@_}->( map { no strict 'refs'; ${"Person::address_$_"} } 1..3 );

Replies are listed 'Best First'.
Re^4: How can I access package variables in a dynamic way
by bangor (Monk) on Feb 12, 2019 at 15:43 UTC
    Unfortunately yes it really is. That does look like a solution - thanks.