Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Can a hash self reference?

by coke (Acolyte)
on Jul 01, 2005 at 15:33 UTC ( #471754=note: print w/replies, xml ) Need Help??


in reply to Can a hash self reference?

Your problem, I think, is that you're trying to do this all at once - at the time you ask for the self-referencing portion, it's not actually been stored in the hash yet. You need to break this up into smaller chunks, so that the values you want are defined by the time you ask for them:
my %hash; $hash{1}{ONE} = "testdir"; $hash{1}{TWO} = "tmpdir"; $hash{2}{LOCATIONA} = "$hash{1}{ONE}/$hash{1}{TWO}/my_file.txt"; $hash{2}{LOCATIONB} = "$hash{1}{TWO}/$hash{1}{ONE}/my_file.txt"; print "$hash{2}{LOCATIONA} = location a\n"; print "$hash{2}{LOCATIONB} = location b\n";
as an example.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://471754]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2021-10-24 16:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (89 votes). Check out past polls.

    Notices?