John W. Krahn wrote:
Johnson, Reginald (GTS) wrote:
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.

It looks like you may want something more like this (*UNTESTED*):


#!/usr/bin/perl
use strict;
use warnings;
use POSIX qw/strftime/;

my $today = strftime '%m%d%Y', localtime;

open RMANFILE, '<', "/adsm/ACTIVITIES/ANR4391I/rman_out-$today" or die "RMANFILE could not be opened :$!\n";

my %output_Hash;
while ( <RMANFILE> ) {
    my ( $server, @fields ) = ( split / +/ )[ 0, 1 .. 4,  6 .. 8 ];
@{ $output_Hash{ $server } }{ qw/db obj oldate tb past bkupserv lastbkup/ } = @fields;
    }
close RMANFILE;

open EXPFILE, '<', '/adsm/ACTIVITIES/ANR4391I/expfile' or die "Could not open EXPFILE :$!\n";

while ( <EXPFILE> ) {
    my ( $exp_servname, $exp_date ) = split;
    my ( $exp_serv ) = split /_ORA/, $exp_servname;
$output_Hash{ $key }{ exp_date } = exists $output_Hash{ $key } ? $exp_date : '---';

Correction:

$output_Hash{ $exp_serv }{ exp_date } = exists $output_Hash{ $key } ? $exp_date : '---';


    }
close EXPFILE;

for my $key ( keys %output_Hash ) {
print "$key @{$output_Hash{$key}}{qw/db obj oldate tb past bkupserv lastbkup exp_date/}\n";
    }

__END__


John
--
Those people who think they know everything are a great
annoyance to those of us who do.        -- Isaac Asimov

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to