tag:blogger.com,1999:blog-3095960273340541911.post1367075849303692212..comments2023-07-08T09:00:52.417-07:00Comments on Software Engineer of Danger: Hash de-duplication in PerlAnonymoushttp://www.blogger.com/profile/08250667223130135379noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-3095960273340541911.post-42924185590458238052012-02-05T19:51:46.555-08:002012-02-05T19:51:46.555-08:00This is a common problem and it's great to see...This is a common problem and it's great to see a nice, succinct solution.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3095960273340541911.post-5665952419839045622012-02-05T12:13:39.677-08:002012-02-05T12:13:39.677-08:00Instead of filling the hash with a loop or map you...Instead of filling the hash with a loop or map you could use:<br /><br />my %number_hash ;<br />@number_hash{@list} = undef ;<br />my @unique_numbers = keys %number_hash ;Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3095960273340541911.post-6973240901241627752012-02-05T03:52:13.215-08:002012-02-05T03:52:13.215-08:00an even shorter way to get the hash filled could b...an even shorter way to get the hash filled could be:<br /><br />my %number_hash = map { $_ => 1 } @list;<br /><br />and yet shorter:<br /><br />use List::MoreUtils qw(uniq);<br />my @unique_numbers = uniq @list;Anonymousnoreply@blogger.com