in reply to search and replace

You have to change your regular expression here

while ( <DATA> ) { my ( $key, $val ) = /^(\d+)\s+(\w+)/; $val = lc($val); $dict{ $val } = $key; }

Try printing print Dumper \%dict and you can find the mistake

When I printed the $key and $value the result is as follows

my %dict; while ( <DATA> ) { my ( $key, $val ) = /^(\d+)\s+(\w+)/; print "$key\t$val\n"; $val = lc($val); $dict{ $val } = $key; } __END__ 1 cross 2 reference 3 cross

So the $dict{cross}=>1 is getting overwrite

--Lakshmanan G.

The great pleasure in my life is doing what people say you cannot do.