in reply to Re: Hash Multiple values for a key-Filtering unique values for a key in hash
in thread Hash Multiple values for a key-Filtering unique values for a key in hash

Thanks. How can i put this in my script ? is like below

make_uniq(\%hashref); dd $hashref; sub make_uniq { my ($hr) = @_; $_ = [ uniq @$_ ] for values %$hr; }
  • Comment on Re^2: Hash Multiple values for a key-Filtering unique values for a key in hash
  • Download Code

Replies are listed 'Best First'.
Re^3: Hash Multiple values for a key-Filtering unique values for a key in hash
by AnomalousMonk (Archbishop) on May 23, 2017 at 04:06 UTC
    How can i put this in my script ?

    If your data is held in the form of a hash (not a hash reference), e.g.

    my %hash = ( 'Alabama' => [ qw(Andalusia Anniston Clanton Eufaula Auburn Bessemer Eufaula Auburn Bessemer) ], 'California' => [ qw(Barstow Barstow) ], 'Georgia' => [ qw(Darien) ], 'New York' => [ 'Coney Island', qw(Amsterdam Beacon Becon), 'Coney Island', ], );
    the following works (tested):
    make_uniq(\%hash); dd \%hash;


    Give a man a fish:  <%-{-{-{-<