zerocred has asked for the wisdom of the Perl Monks concerning the following question:
However - this duplicates the great big chunks of dereferencing code... When there are duplicates, I only need the first one so only need branches under $content->{'A'}[0]{etc}...if(ref($content->{'A'}) eq 'ARRAY'){ # this is an array so need the [0] in there $x=$content->{'A'}[0]{'R1'}{'T1'}{'S1'}, $y=$content->{'A'}[0]{'R1'}{'T1'}{'content'} . . # more dereferencing further along the tree }else{ # this is not an array $x=$content->{'A'}{'R1'}{'T1'}{'S1'}, $y=$content->{'A'}{'R1'}{'T1'}{'content'} . . # more dereferening further along the tree }
but that didn't work.$ifarray = "{'A'}[0]" else $ifarray = "{'A'}"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Test for array or hash - ok, but what to do about it?
by Fletch (Bishop) on May 17, 2009 at 16:16 UTC | |
|
Re: Test for array or hash - ok, but what to do about it?
by Anonymous Monk on May 17, 2009 at 16:07 UTC | |
by Jenda (Abbot) on May 17, 2009 at 21:46 UTC | |
|
Re: Test for array or hash - ok, but what to do about it?
by zerocred (Beadle) on May 17, 2009 at 16:39 UTC |