Re: Need some help...
Rocco Caputo <[email protected]>
| Newsgroups | gmane.comp.lang.perl.poe |
|---|---|
| Message-ID | <[email protected]> |
Sorry, works for me:
% perl -Mstrict -MPOE -MData::Dumper -wle '
quote> my $self = bless { key => "value" };
quote>
quote> POE::Session->create(
quote> object_states => [ $self => ["_start"] ],
quote> heap => { alias => "Alias" }
quote> );
quote>
quote> sub _start {
quote> my ($k, $s, $h) = @_[KERNEL, OBJECT, HEAP];
quote> print Dumper("in _start", $s, $h);
quote> }
quote>
quote> POE::Kernel->run()'
$VAR1 = 'in _start';
$VAR2 = bless( {
'key' => 'value'
}, 'main' );
$VAR3 = {
'alias' => 'Alias'
};
--
Rocco Caputo - [email protected]
On Jun 13, 2009, at 21:20, Rob Fugina wrote:
> A nasty error no doubt due to my rapid attempt at whipping up an
> example program. I've checked my original code suffering from the
> problem, and it doesn't suffer from the same problem.
>
> In my other code, I'm still having problems finding the object
> reference in the _start handler (or any other, but one thing at a
> time...). Here's the code for _start.
>
> sub _start
> {
> my ($kernel, $self, $heap) = @_[KERNEL, OBJECT, HEAP];
> $kernel->alias_set($heap->{alias}) if defined $heap->{alias};
> print Dumper('in _start', $self, $heap);
> $kernel->alias_set($self->address);
> }
>
> It's failing on the last line, because $self is undef. The dump in
> the line before it, however, shows the object showing up in HEAP's
> position, otherwise structured and blessed as it should be. I also
> dump the session object from the main program right after it's
> created, and it also looks fine. Not that I'm familiar with POE
> internals, but in particular, the dispatch table shows _start listed
> with a reference to the object and its _start method, right where they
> were in the sample program previously sent.
>
> Here's the Session creation in case it's useful for verifying
> anything... Not much there yet.
>
> POE::Session->create(
> object_states => [
> $self => [ qw( _start ) ],
> ],
> heap => {
> alias => $params{Alias},
> description => $params{Description} ||
> uc($params{Address}),
> },
> );
>
> If you need to see more code and you're willing to help me further,
> I'd be more than happy to share. Thank you for your quick attention
> so far!
>
> Rob