Tim Klein wrote:
I expected the following short program to print "My name is Tim"
followed by "My name is Mud". Instead, this is the output:
My name is
Use of uninitialized value in concatenation (.) or string at opt.pl
line 25.
My name is Mud
Apparently, the 'MyName' option isn't getting registered properly
during the creation of the session. But when I later set the same
option using the option() command, it works fine.
Can someone spot what I'm doing wrong, most likely in my create()
call? It's probably something stupid, but I just can't see it. Thanks
for any help!
Tim
------------------------------------
#!/usr/bin/perl
use warnings;
use strict;
use POE;
POE::Session->create
(
inline_states =>
{
_start => \&startup,
event1 => \&handler1,
event2 => \&handler2,
},
options => { 'MyName' => 'Tim' },
);
POE::Kernel->run();
sub startup { $_[KERNEL]->yield('event1'); }
sub handler1 {
my $name = $_[SESSION]->option( 'MyName' );
print "My name is $name\n";
$_[KERNEL]->yield('event2');
}
sub handler2 {
$_[SESSION]->option( 'MyName', 'Mud' );
my $name = $_[SESSION]->option( 'MyName' );
print "My name is $name\n";
}
To be honest, I don't think that's expected behavior of POE::Session,
it's better to store your stuff in the HEAP instead of mucking around
with options.
However, I don't see why your example fails, my brain must be dead
because I don't see anything funky in the source for POE::Session...
--
Apocalypse
Homepage: http://JiNxEdStAr.0ne.us
IRC: Apocalypse@xxxxxxxxxxxx
IRC: Apocalypse@xxxxxxxxxxxxxxxx
Perl Stuff: http://search.cpan.org/~APOCAL/
|
Try Searching:
servers, voip, java, networking, microsoft ...
|
|
|
|