0

I have the following code that returns a reference to an array with one element. That element contains a reference to a hash. I would like to eliminate this double referencing and work either with a copy of the hash or directly on the hash itself so I can use the keys.

Here's the code:

my $extracted = $db_obj->extract('source_tag', $source_tag);

So $extracted contains a reference to an array. That array has a single element, a reference to a hash. The hash looks like this when I use Data::Dumper:

    $VAR1 = \\[
              {
                'data_center' => 'qe76',
                'description' => 'locator',
                'abs_delta_dollar_percent' => undef,
                'content_type' => 'Raw',
                'source_tag' => 'hg9efx4',
                'producer' => 'partner',
                'id' => '15282',
                'storage_type' => 'box',
                'storage_path' => '/mnt/storage/2012'
              }
            ];

I'd like to be able to directly access the hash so I can use the keys to grab the values. How do I remove this double referencing?

3 Answers 3

1
my %hash = %{ $db_obj->extract('source_tag', $source_tag)->[0] } ;
Sign up to request clarification or add additional context in comments.

Comments

1
my $extracted = $db_obj->extract('source_tag', $source_tag) -> [0];

Comments

0

That seems to be:

$$$$result[0] 
or 
$$$result[0] 

if you didn't mean that double backslash.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.