in reply to finding the keys with mutliple values in hash and delete them

hi kiransmailid and welcome,

what have you tried and where you encounter problems?
you have an HashOfArrays as described in perldsc.
i think you can simply cycle the hash and check for the presence of the element 1 of the array that is the value for that key of the hash.

L*
perl -MData::Dumper -e " %h = ('Message2' => [ '0X026007' ], 'Message +4' => [ '0X026005', '0X026006' ] ); foreach $k(keys %h) { delete $h{$k} if defined $h{$k}[1] } print Dumper(\%h) " $VAR1 = { 'Message2' => [ '0X026007' ] };
UPDATE: in the remote past existed caveats about modifying hashes while iterating over them; we are speaking of Perl release prior 5.8 see Adding or removing keys while iterating over a hash Re: Deleting Hash Entries while Iterating

L*
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Replies are listed 'Best First'.
Re^2: finding the keys with mutliple values in hash and delete them
by Not_a_Number (Prior) on Mar 19, 2015 at 09:36 UTC

    Minor nitpick: I'd use exists rather than defined, in the (probably very unlikely) event of something like

    'Message5' => [ '0X026008', undef, '0X026009' ]
Re^2: finding the keys with mutliple values in hash and delete them
by kiransmailid (Initiate) on Mar 19, 2015 at 11:01 UTC
    WOW !!!
    Thanks a Lot, that works :)