in reply to Hash reference

If I understand you correctly, I think this is what you want: myfunc($a_ref->{$w}).