Need some help...

Rob Fugina <[email protected]>
Newsgroups gmane.comp.lang.perl.poe
Message-ID <[email protected]>
I've been away from the list for a while, but now I'm wondering if
everyone else hasn't, as well.  Is anybody still here?

I've been having some trouble writing a couple of modules with object
states recently -- usually I stick to inline states -- and I was
hoping someone here would be able to give me some advice.  Maybe
someone can start by explaining why in the attached program it seems
that the parameters aren't lined up properly with the constants
(OBJECT, SESSION, HEAP, etc...).  The result is a mess...

Thanks,
Rob
objtest.pl (application/x-perl, 894 B)
#!/usr/local/bin/perl

use POE;
use Data::Dumper;

use strict;

my $session = TestPkg->spawn('my_alias');

print Dumper('dump of session', $session);

$poe_kernel->post($session, 'other');

POE::Kernel->run();

exit;

package TestPkg;

use POE;
use Data::Dumper;

sub spawn
{
	my $type = shift;
	my $alias = shift;
	my $self = $type->new($alias);
	print Dumper('dump of object', $self);
	POE::Session->create(
		object_states => [
			$self => [ qw( _start other ) ],
			],
		heap => {
			heap_key_1 => 1,
			},
		);
}

sub new
{
	my $type = shift;
	my $href = { @_ };
	return bless $href, $type;
}

sub _start
{
	my ($kernel, $self, $heap) = $_[KERNEL, OBJECT, HEAP];
	print Dumper('dump in _start', $self, $heap, ref $kernel);
}

sub other
{
	my ($kernel, $self, $heap, $session) = $_[KERNEL, OBJECT, HEAP, SESSION];
	print Dumper('dump in other', $self, $heap, ref $session, ref $kernel);
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.