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

Re: Conditional variable assignments

by dvergin (Monsignor)
on May 26, 2003 at 05:15 UTC ( #260774=note: print w/ replies, xml ) Need Help??


in reply to Conditional variable assignments

This is a different approach which may or may not suit your needs:

my %types = ( 0 => 'male', 1 => 'female', 2 => 'robot' ); $this_user = $types{$some_value};
Or, if you are going to use the categories only one time, you can code them as an on-the-fly anonymous hash...
$this_user = { 0 => 'male', 1 => 'female', 2 => 'robot' }->{$some_value};
HTH, David

------------------------------------------------------------
"Perl is a mess and that's good because the
problem space is also a mess.
" - Larry Wall


Comment on Re: Conditional variable assignments
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2015-07-05 04:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls