Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Automating dispatch tables

by liz (Monsignor)
on Apr 16, 2004 at 07:45 UTC ( [id://345671]=note: print w/replies, xml ) Need Help??


in reply to Automating dispatch tables

Nice. However, I don't like the package main, because you can never be certain that that's the original package name (as a code practice, not in this example, obviously).

I would have written this as:

{ package dispatch; sub foo {} sub bar {} sub baz {} sub qux {} } if( my $ref = dispatch->can($method) ) { $ref->(); }
This automatically returns the package to the original package after the definition of the dispatch table.

Liz

Replies are listed 'Best First'.
Re: Re: Automating dispatch tables
by BUU (Prior) on Apr 16, 2004 at 07:53 UTC
    Ah. Clever. I just assumed you would know what package you should be returning to :)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (8)
As of 2024-03-28 12:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found