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.
#!/usr/bin/perl use strict; use warnings; open(SUMMARY, "<", "/home/johnsre/SCRIPTS/BKUPINFO/summary_1269822") or die "summary file cannot open $!\n"; open(ACTLOG, "<", "/home/johnsre/SCRIPTS/BKUPINFO/actlog1269822") or die "actlog file cannot open $!\n"; my $servername="BCCMD1"; my @sumArr; $#sumArr =-1; while (<SUMMARY>) { chomp($_); push(@sumArr,$_); } #end while my @smallsumArr; $#smallsumArr =-1; @smallsumArr = grep(/$servername/, @sumArr); my %sumHash=(); for my $sumindex(0..($#smallsumArr)) { (my ($tsmserver,$sumstart,$sumend,$activity,$sessnumber,$sessnode,$tcpip,$ip address,$sumsched,$sumexamined,$sumaff,$sumfailed,$sumbytes,$sumallthere st)) = split(/,/,$smallsumArr[$sumindex]); $sumHash{$sessnumber} = "$sessnode,$sumstart,$sumend,$sumbytes"; } my @actArr; $#actArr=-1; while (<ACTLOG>) { push (@actArr, $_); } my %actHash=(); for my $actindex(0..($#actArr)) { (my ($acttsmser,$actstart,$actnode,$actsess,$actmess),) =split(/,/,$actArr[$actindex]); $actHash{$actsess} = $actmess; } my ($key,$value,$actkey); for $key (keys %sumHash) { $value = $sumHash{$key}; # print "$key => $value\n"; for $actkey (keys %actHash) { if ($key eq $actkey) { print "output=>$sumHash{$key},$actkey,$actHash{$actkey}"; } #end if } #for }#end for close(SUMMARY); close(ACTLOG); -------------------------------------------------------- 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. 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. --------------------------------------------------------