>>>>> "George" == George Bouras <
f...@example.com> writes:
George> I want to iterate the unique values of a hash, without poluting
George> the code with extra hash definition. Any better idea than
George> my %hash = ( k1=>'v1', k2=>'v1', k3=>'v2', k4=>'v2' );
George> foreach ( sub{local $_={}; @{$_}{@_}=1; keys %{$_}}->(values
George> %hash) ) { say $_; }
Yes. Anything *but* that. You're not golfing here.
my %hash = ( k1=>'v1', k2=>'v1', k3=>'v2', k4=>'v2' );
{
my %u;
@u{values %hash} = ();
print "$_\n" for sort keys %u;
}
And even *that* could use a comment or two for junior devs.
print "Just another Perl hacker,"; # the original
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. -
+1 503 777 0095
<
mer...@stonehenge.com> <URL:
http://www.stonehenge.com/merlyn/>
Perl/Dart/Flutter consulting, Technical writing, Comedy, etc. etc.
Still trying to think of something clever for the fourth line of this .sig