Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
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."

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://117978]
help
Chatterbox?
[moritz]: but even if I had all the time in the world, I wouldn't spend much on perlmonks
[LanX]: holli: LOL
[LanX]: moritz: why ? family?
[LanX]: or other language?
[moritz]: LanX because of usability issues, and the lack of evolvement
[holli]: lol to the robust charme or to the data transfer?
[holli]: it works fine with Lynx though :)
[LanX]: it's easier to patch then to migrate to a PHP board, there are many semantics like linking , authorisation, templates ,...
[LanX]: I've only seen 30% of the semi professional documentation
[holli]: i was just thinking of the bare content.

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (8)
As of 2017-11-20 19:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (292 votes). Check out past polls.

    Notices?