perl hash ..confused

hi
i want to generate standard file from log file. log file containts information about files which are copied to testing region. log files looks as follows

date           time          label                file                 ver      date 
2007-12-13 20:25        SPR 30417       CI0051.COB      1.35    20071213        /Clients/NCB/BANCS-24/cob/CI0051.COB    /BASE/src/CI0051.COB
2007-12-13 20:35        SPR 30418       060658.xml      1.2     20071213        /Clients/NCB/Frontend/xml/Transactions/060658.xml       /FEBase/xml/Transactions/060658.xml
2007-12-13 20:39        SPR 30417       IN0011.COB      1.7     20071213        /Clients/NCB/BANCS-24/cob/IN0011.COB    /BASE/src/IN0011.COB
2007-12-13 21:17        SPR 30417       032001.htm      1.1     20071213        /Clients/NCB/Frontend/html/032001.htm   /FEBase/html/032001.htm

now there can be many entries for single file but with different versions but i want that only file with latest version should be present in new file.
i am using perl for this there are total 5 scripts to do final job 4 are ready i am stuck with this one to get unique components only

for eg if input file is

.....IN0000.COB     1.2     ......
.....login.htm         1.1     .....
.....IN0000.COB     1.3     ....
           .
           .

oputfile should be

.....login.htm         1.1     .....
.....IN0000.COB     1.3     ....
                 .
                 .

i have hash in which i store file name and its key is version no i check entry of file in hash if its there then i comaprare otherwise i add in hash but what i want is that other information on that is importatnt for same file ii may change also like version label so final file should be list of uniq files with all other information intact as shown in first file.

I'm not totally sure what you want to do. But to limit display of lines with identical filename to the highest version only, you can put the line into the hash and after filtering you will get what you want. Here is an example (5 lines into 4):

@lines = split(/\n/, "2007-12-13 20:25        SPR 30417       CI0051.COB      1.35    20071213        /Clients/NCB/BANCS-24/cob/CI0051.COB    /BASE/src/CI0051.COB
2007-12-13 20:35        SPR 30418       060658.xml      1.2     20071213        /Clients/NCB/Frontend/xml/Transactions/060658.xml       /FEBase/xml/Transactions/060658.xml
2007-12-19 20:35        SPR 30418       060658.xml      1.12     20071219        /Clients/NCB/Frontend/xml/Transactions/060658.xml       /FEBase/xml/Transactions/060658.xml
2007-12-13 20:39        SPR 30417       IN0011.COB      1.7     20071213        /Clients/NCB/BANCS-24/cob/IN0011.COB    /BASE/src/IN0011.COB
2007-12-13 21:17        SPR 30417       032001.htm      1.1     20071213        /Clients/NCB/Frontend/html/032001.htm   /FEBase/html/032001.htm");

sub ver_compare {
my ($a2, $b2) = map { [split(/\./, $_)] } @_;
return ($a2->[0] <=> $b2->[0] || $a2->[1] <=> $b2->[1]);
}

%line_maxvers = ();
foreach $line (@lines) {
($date, $time, $label1, $label2, $fn, $ver) = split(/\s+/, $line);
$line_maxvers{$fn} = [$ver, $line] if (!$line_maxvers{$fn} || ver_compare($ver, $line_maxvers{$fn}) > 0);
}

foreach (values %line_maxvers) {
print $_->[1], "\n";
}

hi
thanks cbkihong for ur reply

got what is the error in my code following link provided good help

Perl Hash Howto

my file which is input to this script :

2007-12-13 20:25	SPR 30417	CI0051.COB	1.35	20071213	lanthanum	abcdefg	/ABC/efg/BANCS-24/cob/CI0051.COB	/BASE/src/CI0051.COB
2007-12-13 20:35	SPR 30418	060658.xml	1.2	20071213	lanthanum	abcdefg	/ABC/efg/Frontend/xml/Transactions/060658.xml	/FEBase/xml/Transactions/060658.xml
2007-12-13 20:39	SPR 30417	IN0011.COB	1.6	20071213	lanthanum	abcdefg	/ABC/efg/BANCS-24/cob/IN0011.COB	/BASE/src/IN0011.COB
2007-12-13 21:17	SPR 30417	032001.htm	1.1	20071213	lanthanum	abcdefg	/ABC/efg/Frontend/html/032001.htm	/FEBase/html/032001.htm
2007-12-13 23:00	SPR 30251	CommissionFetch.htc	1.5	20071213	Khalid	abcdefg	/ABC/efg/Core/htc/FlowComponents/CommissionFetch.htc	/FEBase/htc/FlowComponents/CommissionFetch.htc
2007-12-13 20:39	SPR 30410	IN0011.COB	1.7	20071213	lanthanum	abcdefg	/ABC/efg/BANCS-24/cob/IN0011.COB	/BASE/src/IN0011.COB

output i am getting with this error :

# display from subroutine stored indicates version stored in hash and read is one which need to be compared 
# stored : HASH(0x4014f620) 	 read : 1.7
# HASH(0x4014f620)0000000000000000000000000000 :1st sting 
#00010007000000000000000000000000 :2nd sting 
/Clients/NCB/Frontend/html/032001.htm	1.1	20071213	SPR 30417	/FEBase/html/032001.htm
/Clients/NCB/Frontend/xml/Transactions/060658.xml	1.2	20071213	SPR 30418	/FEBase/xml/Transactions/060658.xml
/Clients/NCB/BANCS-24/cob/CI0051.COB	1.35	20071213	SPR 30417	/BASE/src/CI0051.COB
/Clients/NCB/Core/htc/FlowComponents/CommissionFetch.htc	1.5	20071213	SPR 30251	/FEBase/htc/FlowComponents/CommissionFetch.htc
Can't use string ("CommissionFetch.htc") as a HASH ref while "strict refs" in use at test.pl line 56, <PROLOG> line 6.

Now getting the proper output

/ABC/efg/Frontend/html/032001.htm   1.1     20071213        SPR 30417       /FEBase/html/032001.htm
/ABC/efg/Frontend/xml/Transactions/060658.xml       1.2     20071213        SPR 30418       /FEBase/xml/Transactions/060658.xml
/ABC/efg/BANCS-24/cob/CI0051.COB    1.35    20071213        SPR 30417       /BASE/src/CI0051.COB
/ABC/efg/Core/htc/FlowComponents/CommissionFetch.htc        1.5     20071213        SPR 30251       /FEBase/htc/FlowComponents/CommissionFetch.htc