Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Strict, strings and subroutines

by davorg (Chancellor)
on Oct 10, 2001 at 16:18 UTC ( #117978=note: print w/ replies, xml ) Need Help??


in reply to Strict, strings and subroutines

I'd do this by creating a hash of references to the various subroutines like this:

sub do_x { print "processing x\n"; } sub do_y { print "processing y\n"; } my %subs = ( x => \&do_x, y => \&do_y );

Then when you know what type you're going to be processing, you can do something like this:

$subs{$type}->();
--
<http://www.dave.org.uk>

"The first rule of Perl club is you don't talk about Perl club."


Comment on Re: Strict, strings and subroutines
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2014-08-23 07:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (172 votes), past polls