Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Return value from code reference stored in dispatch table

by davido (Cardinal)
on Sep 01, 2013 at 03:25 UTC ( [id://1051766]=note: print w/replies, xml ) Need Help??


in reply to Return value from code reference stored in dispatch table

You haven't shown us enough to demonstrate the problem.

use strict; use warnings; # $RtnVal = $ActionSubsM{$FormCmd}->( $FORM{'meetingid'} ); my %ActionSubsM; my $FormCmd = "some_action"; my %FORM; $FORM{meetingid} = "Hello world!\n"; $ActionSubsM{$FormCmd} = sub { return shift; }; my $RtnVal = $ActionSubsM{$FormCmd}->( $FORM{'meetingid'} ); print $RtnVal;

...outputs...

Hello world!

The code you are demonstrating is correct if the code you haven't demonstrated provides the necessary setup.

The best thing you could do is boil your problem down to a 10 to 20 line example that can be executed, and that will exhibit the problem you're facing. There's a strong chance that in doing so, you'll find the problem yourself anyway. And if not, you will have something you can post for us to look at. ;)


Dave

Replies are listed 'Best First'.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2024-04-24 17:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found