I have a program which returns backup data. It currently uses only one function of a module an I would like to modify it to use others.

Truncated contents of %images:

172 'galahad_1023056445' 173 HASH(0x5cdf98) 'backup_id' => 'galahad_1023056445' 'backup_status' => 0 'backup_time' => 1023056445 'bi_full_time' => 0 'class' => 'MII-AFS-Filesystem' 'class_type' => 'Standard (0)' 'client' => 'galahad' 'id' => 'CC0981'

Truncated contents of %jobs:


68 212844 69 HASH(0x7eff68) 'class' => 'NT-Development' 'classtype' => 13 'client' => 'ahrdev' 'compression' => 0 'elapsed' => 0000037093 'ended' => 1022923736 'filelistcount' => 1 'files' => 'ALL_LOCAL_DRIVES' 'fileslastwritten' => 0 'group' => '' 'jobid' => 212844 'jobpid' => 17667 'jobtype' => 'immediate' 'kbytes' => 295857

 %images and %jobs are populated like this:

my %images = bpimagelist('$record->{client}'); my %jobs = bpdbjobs();

Subroutine which produces desired output:

sub post2Web { my $jRef = shift(); my $infoformat = "%-30s %-40s\n"; ### Base directory of Web database my $base = '/usr/openv/netbackup/jobs/db'; ### Job ID index directory my $jidbase = '/usr/openv/netbackup/jobs/byJobID'; ### make today's client directory if ! exist my $bkup_date = strftime "%Y%m%d", localtime($jRef->{started}); my $wkdir = "$bkup_date/TEST/$jRef->{client}"; mkpath("$base/$wkdir", 0, 0755) unless -d "$base/$wkdir"; ### make directory to hold class/schedule/jobid info my $csdir = "$jRef->{class}/$jRef->{schedule}/$jRef->{jobid}"; mkpath("$base/$wkdir/$csdir", 0, 0755) unless -d "$base/$wkdir/$csdir" +; symlink "../db/$wkdir/$csdir", "$jidbase/$jRef->{jobid}"|| die "$!"; open(INFO, ">$base/$wkdir/$csdir/info") || die "Unable to open/write + $base/$wkdir/csdir/info, $!"; printf INFO $infoformat, "jobid", $jRef->{jobid}; printf INFO $infoformat, "jobtype", $jRef->{jobtype}; printf INFO $infoformat, "state", $jRef->{state}; printf INFO $infoformat, "status", $jRef->{status}; printf INFO $infoformat, "client", $jRef->{client}; printf INFO $infoformat, "server", $jRef->{server}; printf INFO $infoformat, "stunit", $jRef->{stunit}; printf INFO $infoformat, "started", $jRef->{started}; printf INFO $infoformat, "elapsed", $jRef->{elapsed}; printf INFO $infoformat, "ended", $jRef->{ended}; printf INFO $infoformat, "files", $jRef->{files}; printf INFO $infoformat, "Mbytes", $jRef->{Kbytes}; printf INFO $infoformat, "kbytes last written", close INFO; } </CODE<p> What I want to do is incorporate pertinent values from <CODE> %image
in the output.
This separate piece of code will give me the desired output, but I just don't know how to combine the two.
#!/usr/local/bin/perl -w use strict; use NBUX; my $record; my %images = bpimagelist('$record->{client}'); foreach my $key (sort keys %images) { prtID($images{$key}); } sub prtID { my $ref = shift; print "client = $ref->{client}\n"; print "\tid= $ref->{id}\n"; }

Sorry if this is a little verbose; please feel free to say so.

Edit kudra, 2002-06-06 Added readmore


In reply to Hash dereferencing and printing by Anonymous Monk

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.