Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

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

by broquaint (Abbot)
on Jul 19, 2002 at 17:51 UTC ( #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? | Other CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2023-03-25 17:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which type of climate do you prefer to live in?






    Results (63 votes). Check out past polls.

    Notices?