I'm having a hard time accessing and printing variables contained in the data structure below.

Specifically, what I'm looking for out of this is:

key = intra-d_1050044970
frag1 media ID = DA0006
frag2 media ID = DA0006
image kilobytes = 713865 image number_of_files = 143

I've tried the following; as you can see, I'm fairly lost in this problem:

#!/opt/openv/perl/bin/perl -w use strict; use Data::Dumper; use bpimagelist; my %images = sls_bpimagelist(); #print Dumper(\%images); foreach my $img ( sort keys %images ) { foreach ( @{$images{$img}} ) { print "key = $img"; foreach ( @{$images{$img}{'media_id'}} ) { print "ID = $_\n"; } } }
This returns:

Not an ARRAY reference at /opt/openv/scripts/orapt.pl line 11.

Can anyone help me unwind this data structure?

Thx, Steve

'intra-d_1050044970' => { 'frags' => [ [ { 'media_id' => 'DA0006', 'density' => '21', 'flags' => '0', 'file_num' => '31', 'i_unused1' => '0', 'mpx' => '1', 'i_unused2' => '0', 'i_unused3' => '65539', 'block_size' => '65536', 'f_unused1' => '*NULL*', 'frag_num' => '1', 'media_date' => '1049782622', 'host' => 'bkup1', 'remainder' => '0', 'copy_num' => '1', 'expiration_time' => '1052723370', 'offset' => '1426484', 'kilobytes' => '168384', 'dev_written' => '8' }, { 'media_id' => 'DA0006', 'density' => '21', 'flags' => '0', 'file_num' => '32', 'i_unused1' => '0', 'mpx' => '0', 'i_unused2' => '0', 'i_unused3' => '0', 'block_size' => '65536', 'f_unused1' => '*NULL*', 'frag_num' => '2', 'media_date' => '1049782622', 'host' => 'bkup1', 'remainder' => '512', 'copy_num' => '1', 'expiration_time' => '0', 'offset' => '1434968', 'kilobytes' => '545481', 'dev_written' => '8' } ] ], 'histo' => { 'f1' => '-1', 'f2' => '-1', 'f3' => '-1', 'f4' => '-1', 'f5' => '-1', 'f6' => '-1', 'f7' => '-1', 'f8' => '-1', 'f9' => '-1', 'f10' => '-1' }, 'image' => { 'class_type' => '0', 'mpx' => '1', 'schedule_type' => '0', 'proxy_client' => '*NULL*', 'keyword' => '*NULL*', 'number_of_frags' => '2', 'retention_level' => '3', 'elapsed_time' => '146', 'tir_expiration' => '0', 'request_id' => '0', 'blob_inc_full_time' => '0', 'kilobytes' => '713865', 'dump_level' => '0', 'db_compressed' => '0', 'creator' => 'root', 'software_versoin' => '6', 'image_type' => '0', 'ext_security_info' => '0', 'use_file_system' => '0', 'encrypted' => '0', 'client' => 'miidb1-d', 'input_options' => '0', 'object_descriptor' => '*NULL*', 'primary_copy' => '1', 'backup_status' => '0', 'tir_info' => '0', 'backup_id' => 'intra-d_1050044970', 'class' => 'intra-d_misc_os', 'number_of_files' => '143', 'sw_version' => '*NULL*', 'backup_time' => '1050044970', 'prev_blob_inc_time' => '0', 'sched_label' => 'Full', 'compressed' => '0', 'expiration_time' => '1052723370', 'name1' => '*NULL*', 'number_of_copies' => '1' } },

In reply to Accessing/Printing Complex Data Structure by blink

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.