D
doolittle
Hi,
My code stops (with Can't call method "move" on unblessed reference)
when i try to access the methods of a variation object. The first (non
variation) move is shown OK ('2
d' in the output), and when i do
'print Dumper($var);', that kinda looks like its the right sort of
thing, but i can't do anything with it.
Code:
use strict;
use warnings;
use Games::Go::SGF;
use Data:
umper;
my $sgf = new
Games::Go::SGF('(;GM[1]FF[4]SZ[19];B[pd](;W[pp])(;W[cf]))');
print Dumper($sgf);
my $move_no = 1;
while (my $walker = $sgf->move($move_no++)) {
if (ref($walker) eq 'Games::Go::SGF::Node'){
print "$move_no: ".$walker->move,"\n";
}
if (ref($walker) eq 'Games::Go::SGF::Variation'){
my $var = $walker->variation(0);
print Dumper($var);
my $varwalker = $var->move(1); # fails here
print '1: '.$varwalker->move,"\n";
}
}
This prints out:
Can't call method "move" on unblessed reference at go2.pl line 19.
(in cleanup) Can't use string ("Games::Go::SGF::Node:
ESTROY") as a
subroutine ref while "strict refs" in use at
C:/Perl/site/lib/Games/Go/SGF.pm line 83.
$VAR1 = bless( [
bless( {
'next' => bless( {
'next' => bless( [
[
bless( {
'next' => undef,
'W' => 'pp',
'moves_to_first_variation' => 0
}, 'Games::Go::SGF::Node' ),
{
'next' => undef
}
],
[
bless( {
'next' => undef,
'W' => 'cf',
'moves_to_first_variation' => 0
}, 'Games::Go::SGF::Node' ),
{
'next' => undef
}
]
],
'Games::Go::SGF::Variation' ),
'B' => 'pd'
}, 'Games::Go::SGF::Node' ),
'FF' => '4',
'moves_to_first_variation' => 2,
'GM' => '1',
'SZ' => '19'
}, 'Games::Go::SGF::Node' ),
$VAR1->[0]{'next'},
$VAR1->[0]{'next'}{'next'},
{
'next' => undef
}
], 'Games::Go::SGF' );
2: pd
$VAR1 = [
bless( {
'next' => undef,
'W' => 'pp',
'moves_to_first_variation' => 0
}, 'Games::Go::SGF::Node' ),
{
'next' => undef
}
];
My code stops (with Can't call method "move" on unblessed reference)
when i try to access the methods of a variation object. The first (non
variation) move is shown OK ('2
'print Dumper($var);', that kinda looks like its the right sort of
thing, but i can't do anything with it.
Code:
use strict;
use warnings;
use Games::Go::SGF;
use Data:
my $sgf = new
Games::Go::SGF('(;GM[1]FF[4]SZ[19];B[pd](;W[pp])(;W[cf]))');
print Dumper($sgf);
my $move_no = 1;
while (my $walker = $sgf->move($move_no++)) {
if (ref($walker) eq 'Games::Go::SGF::Node'){
print "$move_no: ".$walker->move,"\n";
}
if (ref($walker) eq 'Games::Go::SGF::Variation'){
my $var = $walker->variation(0);
print Dumper($var);
my $varwalker = $var->move(1); # fails here
print '1: '.$varwalker->move,"\n";
}
}
This prints out:
Can't call method "move" on unblessed reference at go2.pl line 19.
(in cleanup) Can't use string ("Games::Go::SGF::Node:
subroutine ref while "strict refs" in use at
C:/Perl/site/lib/Games/Go/SGF.pm line 83.
$VAR1 = bless( [
bless( {
'next' => bless( {
'next' => bless( [
[
bless( {
'next' => undef,
'W' => 'pp',
'moves_to_first_variation' => 0
}, 'Games::Go::SGF::Node' ),
{
'next' => undef
}
],
[
bless( {
'next' => undef,
'W' => 'cf',
'moves_to_first_variation' => 0
}, 'Games::Go::SGF::Node' ),
{
'next' => undef
}
]
],
'Games::Go::SGF::Variation' ),
'B' => 'pd'
}, 'Games::Go::SGF::Node' ),
'FF' => '4',
'moves_to_first_variation' => 2,
'GM' => '1',
'SZ' => '19'
}, 'Games::Go::SGF::Node' ),
$VAR1->[0]{'next'},
$VAR1->[0]{'next'}{'next'},
{
'next' => undef
}
], 'Games::Go::SGF' );
2: pd
$VAR1 = [
bless( {
'next' => undef,
'W' => 'pp',
'moves_to_first_variation' => 0
}, 'Games::Go::SGF::Node' ),
{
'next' => undef
}
];