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

Re: an easier way with grep, map, and/or sort?

by broquaint (Abbot)
on Jul 19, 2002 at 17:51 UTC ( [id://183336]=note: print w/replies, xml ) Need Help??


in reply to an easier way with grep, map, and/or sort?

The initial if block can be simplified to something like this
if(not defined $institution) { $institution_table{ unaffiliated }++; } else { $institution_table{ $_ }++ for grep { $institution eq $_ } ( $hospital1 $hospital2 ); }
But I think that could be cleaned up more by using less singular variables. As for the for loop you're trying to use perl6 style number comparisons and the comparisons don't seem to match the age bracket. Maybe you mean something like this
$institution_table{$_}->{"fortyfive_fifty"} ++ if 45 > $age and $age <= 50;
And the sort() is superfluous in the for loop (well at least from the code provided). Probably the best way to simplify your is to simplify your data structures (as one follows the other). </code>
HTH

_________
broquaint

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-20 04:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found