Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Can a hash self reference?

by coke (Acolyte)
on Jul 01, 2005 at 15:33 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-03-29 12:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found