Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Easier Way?

by FoxtrotUniform (Prior)
on Aug 28, 2002 at 21:30 UTC ( [id://193584]=note: print w/replies, xml ) Need Help??


in reply to Easier Way?

Hmm. values?

my %hash2; for my $val (sort values %hash2) { if(exists $hash2{$val}) { $hash2{$val}++; } else { $hash2{$val} = 1; } }

Not much shorter, but a bit easier to read....

--
F o x t r o t U n i f o r m
Found a typo in this node? /msg me
The hell with paco, vote for Erudil!

Replies are listed 'Best First'.
Re: Re: Easier Way?
by thelenm (Vicar) on Aug 28, 2002 at 21:49 UTC
    In fact, the sort and the if test are unnecessary, so we can further reduce the code to this:
    my %hash2; $hash2{$_}++ for values %hash1;

    -- Mike

    --
    just,my${.02}

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2024-04-23 08:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found