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'
}
},
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.