I am wondering if I am doing this in an efficient manor. I am taking my
first input file and putting it in a hash with server name as a the key.
The second input file has two fields  exp_server and  exp_date. I put
this file in hash using exp_server as the key. I then check if
exp_server exist in the first hash. If it does I out put  the first hash
with the exp_date value. For keys where exp_server doesn't exist I out
put the first hash and "---" for the value of exp_date.


$ cat combine_exprman_perl
#!/usr/bin/perl
use strict;
use warnings;


        my $today;
        $today=`/usr/bin/date +%m%d%Y`;
        chomp $today;
        open (RMANFILE,"<","/adsm/ACTIVITIES/ANR4391I/rman_out-$today")
or
                die "RMANFILE could not be opened :$!\n";

        my
($server,$db,$obj,$oldate,$tb,$dont_need,$past,$bkupserv,$lastbkup);
        my %rman_Hash=();
        while (<RMANFILE>) {
 
($server,$db,$obj,$oldate,$tb,$dont_need,$past,$bkupserv,$lastbkup) =
split(/ +/,$_);
        $rman_Hash{$server}{'db'} = $db;
        $rman_Hash{$server}{'obj'} = $obj;
        $rman_Hash{$server}{'oldate'} = $oldate;
        $rman_Hash{$server}{'tb'} = $tb;
        $rman_Hash{$server}{'past'} = $past;
        $rman_Hash{$server}{'bkupserv'} = $bkupserv;
        $rman_Hash{$server}{'lastbkup'} = $lastbkup;
        } #end while

        my($key, $value);

        open(EXPFILE,"<","/adsm/ACTIVITIES/ANR4391I/expfile") or
                die "Could not open EXPFILE :$!\n";
        my($exp_serv,%exp_Hash);
        while (<EXPFILE>) {
                my($exp_servname,$exp_date)= split(/ /,$_);
                ($exp_serv)= split(/_ORA/,$exp_servname);
                chomp($exp_date);
                $exp_Hash{$exp_serv}{'exp_date'} = $exp_date;
        } #


        my (%output_Hash,$dash);
        $dash="---";
        foreach  $key (keys %exp_Hash) {
                if (exists $rman_Hash{$key}) {
                        $rman_Hash{$key}{'exp_date'} =
$exp_Hash{$key}->{'exp_date'};
                        $output_Hash{$key}{'db'} =
$rman_Hash{$key}->{'db'};
                        $output_Hash{$key}{'obj'} =
$rman_Hash{$key}->{'obj'};
                        $output_Hash{$key}{'oldate'} =
$rman_Hash{$key}->{'oldate'};
                        $output_Hash{$key}{'tb'} =
$rman_Hash{$key}->{'tb'};
                        $output_Hash{$key}{'past'} =
$rman_Hash{$key}->{'past'};
                        $output_Hash{$key}{'bkupserv'} =
$rman_Hash{$key}->{'bkupserv'};
                        $output_Hash{$key}{'lastbkup'} =
$rman_Hash{$key}->{'lastbkup'};
                        $output_Hash{$key}{'exp_date'} =
$exp_Hash{$key}->{'exp_date'};
                } #end if
        }#end foreach
        foreach $key (keys %rman_Hash) {
                if (! exists $output_Hash{$key}) {
                        $output_Hash{$key}{'db'} =
$rman_Hash{$key}->{'db'};
                        $output_Hash{$key}{'obj'} =
$rman_Hash{$key}->{'obj'};
                        $output_Hash{$key}{'oldate'} =
$rman_Hash{$key}->{'oldate'};
                        $output_Hash{$key}{'tb'} =
$rman_Hash{$key}->{'tb'};
                        $output_Hash{$key}{'past'} =
$rman_Hash{$key}->{'past'};
                        $output_Hash{$key}{'bkupserv'} =
$rman_Hash{$key}->{'bkupserv'};
                        $output_Hash{$key}{'lastbkup'} =
$rman_Hash{$key}->{'lastbkup'};
                        $output_Hash{$key}{'exp_date'} = $dash;
                }  #end if
        } #end foreach
        foreach $key (keys %output_Hash) {
                         print  "$key ";
                         print  " $output_Hash{$key}->{'db'} ";
                         print  " $output_Hash{$key}->{'obj'} ";
                         print  " $output_Hash{$key}->{'oldate'} ";
                         print  " $output_Hash{$key}->{'tb'} ";
                         print  " $output_Hash{$key}->{'past'} ";
                         print  " $output_Hash{$key}->{'bkupserv'} ";
                         print  " $output_Hash{$key}->{'lastbkup'} ";
                         print  " $output_Hash{$key}->{'exp_date'}\n";
                } #end foreach

close(RMANFILE);
close(EXPFILE);

--------------------------------------------------------------------------
This message w/attachments (message) may be privileged, confidential or 
proprietary, and if you are not an intended recipient, please notify the 
sender, do not use or share it and delete it. Unless specifically indicated, 
this message is not an offer to sell or a solicitation of any investment 
products or other financial product or service, an official confirmation of any 
transaction, or an official statement of Merrill Lynch. Subject to applicable 
law, Merrill Lynch may monitor, review and retain e-communications (EC) 
traveling through its networks/systems. The laws of the country of each 
sender/recipient may impact the handling of EC, and EC may be archived, 
supervised and produced in countries other than the country in which you are 
located. This message cannot be guaranteed to be secure or error-free. 
References to "Merrill Lynch" are references to any company in the Merrill 
Lynch & Co., Inc. group of companies, which are wholly-owned by Bank of America 
Corporation. Securities and Insurance Products: * Are Not FDIC Insured * Are 
Not Bank Guaranteed * May Lose Value * Are Not a Bank Deposit * Are Not a 
Condition to Any Banking Service or Activity * Are Not Insured by Any Federal 
Government Agency. Attachments that are part of this E-communication may have 
additional important disclosures and disclaimers, which you should read. This 
message is subject to terms available at the following link: 
http://www.ml.com/e-communications_terms/. By messaging with Merrill Lynch you 
consent to the foregoing.
--------------------------------------------------------------------------
 

Reply via email to