Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: Using IF and OR, I'm sure there is a better way

by ikegami (Patriarch)
on Dec 14, 2005 at 23:37 UTC ( [id://516805]=note: print w/replies, xml ) Need Help??

in reply to Using IF and OR, I'm sure there is a better way

And for something completely different:
# Setup my @ok; ++$ok[$_] for 1, 2, 3; # Sample usage if ($ok[$variable]) { ... }
For more flexibility, try a hash:
# Setup my %fruit; ++$fruit{$_} for qw( apple banana orange ); # Sample usage if ($fruit{$object}) { ... }
These are just one step away from a dispatch table:
# Setup my %dispatch = ( colour => \&area_fill, scale => \&scale_image, warp => \&warp_image, ); # Sample usage if ($handler = $dispatch{$command}) { $handler->(); } else { die("Invalid command $command\n"); }

Update: Keep in mind that 1, 2, 3 can be written as 1..3

Log In?

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2024-04-16 08:05 GMT
Find Nodes?
    Voting Booth?

    No recent polls found