Elegant! On Feb 11, 2008 1:35 PM, John W. Krahn <[EMAIL PROTECTED]> wrote: > Johnson, Reginald (GTI) wrote: > > I have two input files and I put each into a hash. If the key of one > > hash matches the other then I output some values from both. I have > > accomplished the output that I want but I want to know if it can be done > > in a more efficient manner. > > Yes. > > #!/usr/bin/perl > use strict; > use warnings; > > my $servername = 'BCCMD1'; > > > open my $ACTLOG, '<', '/home/johnsre/SCRIPTS/BKUPINFO/actlog1269822' > or die "actlog file cannot open $!\n"; > > my %actHash; > while ( <$ACTLOG> ) { > my ( $actsess, $actmess ) = ( split /,/ )[ 3, 4 ]; > $actHash{ $actsess } = $actmess; > } > > close $ACTLOG; > > > open my $SUMMARY, '<', '/home/johnsre/SCRIPTS/BKUPINFO/summary_1269822' > or die "summary file cannot open $!\n"; > > while ( <$SUMMARY> ) { > next if /$servername/; > chomp; > my ( $sumstart, $sumend, $sessnumber, $sessnode, $sumbytes ) = ( > split /,/ )[ 1, 2, 4, 5, 12 ]; > if ( exists $actHash{ $sessnumber } ) { > print > "output=>$sessnode,$sumstart,$sumend,$sumbytes,$sessnumber,$actHash{$sessnumber}"; > } > } > > close $SUMMARY; > > __END__ > > > > John > -- > Perl isn't a toolbox, but a small machine shop where you > can special-order certain sorts of tools at low cost and > in short order. -- Larry Wall > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > http://learn.perl.org/ > > >
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/