Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • 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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-04-19 08:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found