my %h; %hash = ( 1 => { ONE => 'testdir', TWO => 'tmpdir' }, 2 => { LOCATIONA => sub{ qq($hash{1}{ONE}/$hash{1}{TWO}/my_file.txt)}, # Note - wrapped in "sub" LOCATIONB => sub{qq($hash{1}{TWO}/$hash{1}{ONE}/my_file.txt)} } ); print $hash{2}{LOCATIONA}(),qq( = location a\n); #When called like a sub call, produces: # testdir/tmpdir/my_file.txt = location a