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

Running local code on other machines

by spx2 (Deacon)
on Apr 07, 2010 at 10:53 UTC ( #833253=perlquestion: print w/replies, xml ) Need Help??
spx2 has asked for the wisdom of the Perl Monks concerning the following question:

I need to have a central machine and several other machines that do work for it. Now the central machine will send each machine data for it to start processing and a filter function.

I basically need to delegate work to the machines and expect them when they finish to send back results serialized in some way so I can use them.

How do I send this filter function(sub) across the network ? I am thinking maybe of using POE but not sure if it has what I need ? What module(s) should I be using ?


Replies are listed 'Best First'.
Re: Running local code on other machines
by marto (Archbishop) on Apr 07, 2010 at 11:02 UTC
      yes, but how do I serialize a sub and send it on the socket ?

        Be aware that unless your sub is very trivial, you have much more to do than just serialising the sub. If that sub make use of any modules, you'll also have to arrange for those modules to be loaded and initialised at the other machine also. And if those modules use any modules...

        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.
        Umm, serializing a sub is not easy in perl as far as I know, but what about storing your sub's source as a string, send it over the socket as plain text, then eval at the other end of the socket?
        my $sub_str = q{ sub { my $n = shift; return $n + 1; } }; # send the string through the socket # at the far end of the socket: my $sub_ref = eval $sub_str; print $sub_ref->(2), "\n";
        Put it in a module, and use a source control system. (git, hg, svn, cvs, ...)
Re: Running local code on other machines
by tirwhan (Abbot) on Apr 07, 2010 at 14:57 UTC

    The easy way to do this IMO would be to have your central machine turn these subroutines into simple runnable Perl scripts, and send these over the wire in text form. Then have your remote slaves execute these scripts with the appropriate input and send back the output. Whether this is an appropriate way of doing things depends on what exactly these subroutines should do and how often they are run.

    All dogma is stupid.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://833253]
Front-paged by Arunbear
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2018-08-16 00:01 GMT
Find Nodes?
    Voting Booth?
    Asked to put a square peg in a round hole, I would:

    Results (165 votes). Check out past polls.