Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: finding the keys with mutliple values in hash and delete them

by hdb (Monsignor)
on Mar 19, 2015 at 09:21 UTC ( [id://1120549]=note: print w/replies, xml ) Need Help??


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

From all of the keys of your hash, grep those that refer to arrays with length larger than 1, and then delete the corresponding hash slice (all done in one go below):

use strict; use warnings; use Data::Dumper; my %hash = ( 'Message1' => [ '0X026003', '0X026004' ], 'Message2' => [ '0X026007' ], 'Message3' => [ '0X026007' ], 'Message4' => [ '0X026005', '0X026006' ] ); delete @hash{ grep { @{$hash{$_}} > 1 } keys %hash }; print Dumper \%hash;

Replies are listed 'Best First'.
Re^2: finding the keys with mutliple values in hash and delete them
by kiransmailid (Initiate) on Mar 19, 2015 at 11:02 UTC
    Thank You for the Support :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1120549]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2024-03-28 15:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found