Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Weeding out field duplicates - need help!

Status
Not open for further replies.

jeffpas

Programmer
Jul 21, 2008
4
0
0
US
Hi All,

Perl newbie here. I have a conundrum that may be fairly simple to a veteran, but it is causing me grief.

What I have is four fields- Date, Time, Server Name, and Transaction ID.
I want to weed out the duplicate records that have ALL FOUR of these fields the same.

I already have this clip of code which does the following :
##-----------------------------------------------------------
## Display output---

## Remove duplicate records (check by field number)
my $key = join',',(split / /)[1, 2, 3, 4, 9];

printf "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", $mM, '/',

$Fld[2], $yYYY, ' ', $Fld[3], ':', $Fld[4], ':', $Fld[5], ' ',

$aPPNAME, '_', $sEVERITYCODE, ' AFB-I-XXSSOAMP ', $hOSTNAME,

' Tran(', $tRANS, ') Cat(', $cATEGORY, '):', $mESSAGE . $mISSCODE

## Print record only if nonduplicate
unless $hash{$key}++;

Here is what is in $key (example):

Jul,02,15:58:50,us97udp001ampfb.test.ampf.com,trans(1945588)[159.202.168.7]:

The problem is, as the code is currently written, it is only weeding out records that have different Trans ID.
If the Date, Time or Server is different, the record is not passed. I want only records to be skipped if all 4 of these are identical.

Is there an obvious solution I am not seeing?
If I have left information out that is needed, just ask- thanks for any help.

Jeffpas

 
Alright bear with me here folks- I am looking to code this result but it looks like another program may be affecting the output.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top