Subject: | lvalue accessors do not work with debugger |
It seems that lvalue accessors do not work if called from the perl
debugger. I tried the attached script. Running without the debugger
works as expected:
$ perl5.10.0 /tmp/bla.pl
ok 1
1..1
But with the debugger I get an undef:
perl5.10.0 -d /tmp/bla.pl
Loading DB routines from perl5db.pl version 1.3
Editor support available.
Enter h or `h h' for help, or `man perldebug' for more help.
main::(/tmp/bla.pl:6): package Foo;
DB<1> c
not ok 1
# Failed test at /tmp/bla.pl line 16.
# got: undef
# expected: 'bla'
1..1
# Looks like you failed 1 test of 1.
This smells like a perl bug. I tried it with 5.8.8 (as packaged) and
5.10.0 (self-compiled), both on debian, with the same result. I think
you're more skilled with handling lvalues, so it's up to you to report
it to perl5 porters.
Regards,
Slaven
Subject: | bla.pl |
#!/usr/bin/perl
use Test::More 'no_plan';
{
package Foo;
use strict;
use base qw(Class::Accessor::Lvalue);
__PACKAGE__->mk_accessors('bar');
sub new { bless {}, shift }
}
$foo = Foo->new;
$foo->bar = "bla";
is($foo->bar, "bla");