[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Dereferencing question



Greetings,

I know this is the MacPerl list, but I would like to post a pure perl question.

I have some nested hash/array structures and I am having trouble 
dereferencing them all at once.  Up until now, I've been doing it in 
stages, but I'd like to understand how to do it in one fell swoop.

So I have:

my $hRef = {};
my $aRef = [];

$$hRef{'alpha'} = 1;
$$hRef{'beta'} = 2;
$$hRef{'gamma'} = 3;

push @$aRef, "One";
push @$aRef, "Two";
push @$aRef, "Three";

$$hRef{'array'} = $aRef;


Now, I want to push another value onto the embedded array.  I've 
tried all of the following, but none seem to work

push $$hRef{'array'}, "Four";
push @$hRef{'array'}, "Four";
push @($hRef{'array'}), "Four";
push @($$hRef{'array'}), "Four";

    Does anyone have any ideas besides putting the array reference 
into a temporary?

-Andrew
/*-------------------------------------------------------------
Andrew O. Mellinger                      Direct: (503) 265-1220
Critical Path Software, Inc.               Main: (503) 222-2922
General Specialist                          Fax: (503) 222-3020
mailto:andrew@criticalpath.com      http://www.criticalpath.com
-------------------------------------------------------------*/

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org