1 |
#!/usr/bin/perl |
2 |
|
3 |
#sub POE::Kernel::ASSERT_DEFAULT () { 1 } |
4 |
#sub POE::Kernel::TRACE_DEFAULT () { 1 } |
5 |
|
6 |
use POE qw ( Component::SubWrapper ); |
7 |
|
8 |
use Data::Dumper; |
9 |
poeize Data::Dumper; |
10 |
|
11 |
sub _start { |
12 |
my ( $kernel, $heap ) = @_[ KERNEL, HEAP ]; |
13 |
print "1. session started", "\n"; |
14 |
print "2. posting command to \"Data::Dumper\"", "\n"; |
15 |
$kernel->post('Data::Dumper', 'Dumper', [ { a => 1, b => 2 } ], 'callback_handler', 'SCALAR'); |
16 |
$kernel->post('Data::Dumper', 'Dumper', [ { a => 1, b => 2 } ], 'callback_handler', 'SCALAR'); |
17 |
print "3. doing someting here", "\n"; |
18 |
print "4. doing someting here", "\n"; |
19 |
} |
20 |
|
21 |
sub callback_handler { |
22 |
my $result = @_[ARG0]; |
23 |
# do something with the string returned by Dumper({ a => 1, b => 2}) |
24 |
print "2. recieved result: $result", "\n"; |
25 |
} |
26 |
|
27 |
|
28 |
#my @handlers = qw( _start got_child_stdout got_child_stderr got_child_close ); |
29 |
my @handlers = qw( _start callback_handler ); |
30 |
POE::Session->create( package_states => [ main => \@handlers ] ); |
31 |
$poe_kernel->run(); |
32 |
exit; |