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

Re: if or switch?

by pc88mxer (Vicar)
on Jul 10, 2008 at 22:52 UTC ( [id://696846]=note: print w/replies, xml ) Need Help??


in reply to if or switch?

What are your actions for each of the three cases?

If they are very different, then a dispatch table or a Perl6 switch statement is about the most efficient.

If the code for all three cases is very similar, then perhaps this can be made to work for you:

if (m/key(\d)/) { # $1 contains the digit following "key" print "Found key followed by a $1\n" $count{$1}++; print "Total times this key was seen: ", $count{$1}, "\n"; ... }

Log In?
Username:
Password:

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

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

    No recent polls found