Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Can a hash self reference?

by sapnac (Beadle)
on Jul 01, 2005 at 15:49 UTC ( #471761=note: print w/replies, xml ) Need Help??


in reply to Can a hash self reference?

I think you are just trying to understand the concept. Take a look at this. It is tested

Hope it helps...
#!/usr/bin/perl -w use strict; use diagnostics; 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";

Replies are listed 'Best First'.
Re^2: Can a hash self reference?
by tcf03 (Deacon) on Jul 01, 2005 at 17:37 UTC
    Thanks, I was trying to come up with some shortcuts and was failing miserably and the awnsers I got here reminded me I could do the following, this is the actual code.
    my %data = ( DATA => { DIR => "/prod" }, LOGS => { DIR => "/prod/logs" }, SITE1 => { DIR => "/prod/data1", FILE => "/prod/data1/LSTD.DAT" }, SITE2 => { DIR => "/prod/data2", FILE => "/prod/data2/LSTD.DAT" }, LOG1 => { FILE => "/prod/logs/stdaudit01_3 +289.log_1" }, LOG2 => { FILE => "/prod/logs/stdaudit02_8 +750.log_1" } ); # assign $data{$_}{'COPY_D'} and $data{$_}{'COPY_F'} Where needed for ( keys (%data) ) { if ( $data{$_}{'DIR'} ) { $data{$_}{'COPY_D'} = join '', $ARCHIVE +_DIR, $data{$_}{'DIR'} } if ( $data{$_}{'FILE'} ) { $data{$_}{'COPY_F'} = join '', $ARCHIVE +_DIR, $data{$_}{'FILE'} } }


    I just needed to provide an interface to do some copying once a flashcopy is made of a disk...

    Ted
    --
    "That which we persist in doing becomes easier, not that the task itself has become easier, but that our ability to perform it has improved."
      --Ralph Waldo Emerson

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2020-11-30 20:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?