Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: How do you say, in Perl....

by SilasTheMonk (Chaplain)
on May 26, 2011 at 07:03 UTC ( [id://906759]=note: print w/replies, xml ) Need Help??


in reply to How do you say, in Perl....

The question seems pretty vague to me. I have the impression you are trying to do some sort of magic but aren't too clear what. Could you actually try and state what problem you are trying to solve?

Replies are listed 'Best First'.
Re^2: How do you say, in Perl....
by willymacoy (Acolyte) on May 26, 2011 at 09:58 UTC

    I have a message I wish to send. I wish to sign it depending on the content of the message. There will be a default signature. But, if the user wishes he may intercept the signature routine and provide a different signature, by providing another module that is called by the signature routine - if it exists.

    The programming of the signature routines is quite basic. It is just the strategy of having them called without the calling code explicitly call them. After all, I don't know what they are going to be, just that they might be.

    Does that make sense?

        Module::Pluggable - perfect. Dispatch table - yep I can see how I might use that. Abstract factory pattern - this looks quite cool and I think I'll sit down one day and play with it.

        Thanks.

      You might want to pass in a code ref instead of a hash ref, and then in your function you can say:
      my $signature = $custom_coderef ? $custom_coderef->() : default_sig();
      The code ref itself can require any modules it needs, eg:
      my $coderef = sub{ require Foo::Bar; my $signature = "blah"; return $signature; }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-04-16 14:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found