$ cat -n fork5.pl 1 #!/usr/bin/perl -w 2 use strict; 3 use GRID::Machine; 4 use Data::Dumper; 5 6 my $host = $ENV{GRID_REMOTE_MACHINE}; 7 my $machine = GRID::Machine->new( host => $host ); 8 9 my $p = $machine->fork( q{ 10 11 print "stdout: Hello from process $$. args = (@_)\n"; 12 print STDERR "stderr: Hello from process $$\n"; 13 14 use List::Util qw{sum}; 15 return { s => sum(@_), args => [ @_ ] }; 16 }, 17 args => [ 1..4 ], 18 ); 19 20 # GRID::Machine::Process objects are overloaded 21 print "Doing something while $p is still alive ...\n" if $p; 22 23 my $r = $machine->waitpid($p); 24 25 print "Result from process '$p': ",Dumper($r),"\n"; 26 print "GRID::Machine::Process::Result objects are overloaded in a string context:\n$r\n";