dd-b has asked for the wisdom of the Perl Monks concerning the following question:
I've got a simple case working exactly as I expect and as documented, but a more complicated case NOT working. The main difference is that in the more complicated case, I'm accessing a child class of where I did the overload.
In the parent class I do:
use overload '""' => \&_stringify; sub _stringify { my $this = shift; # Actually operator arg, NOT a "this" $this->row->ID; };
I use it like this:
$logger->trace("Zep is " . ref($zep) . " stringifies as $zep" . " but +_stringify returns " . $zep->_stringify );
The resulting log line comes out like this: 20130209 15:27:30.041 TRACE TrafCon.pl 158 6070: Zep is OT::Zeppelin::AddVendorKey stringifies as OT::Zeppelin::AddVendorKey=HASH(0x378d480) but _stringify returns OT::DB::Result::Upload|upload|upload_id=1
OT::Zeppelin::AddVendorKey is a direct child of OT::Zeppelin, which is where the operator overload was done.
My head hurts, and the wall seems to still be fine. Any ideas?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Moose stringification overloading isn't working
by moritz (Cardinal) on Feb 10, 2013 at 09:13 UTC | |
|
Re: Moose stringification overloading isn't working
by tobyink (Canon) on Feb 10, 2013 at 08:54 UTC | |
|
Re: Moose stringification overloading isn't working
by Anonymous Monk on Feb 09, 2013 at 23:48 UTC | |
by dd-b (Pilgrim) on Feb 10, 2013 at 02:34 UTC | |
by Anonymous Monk on Feb 10, 2013 at 07:54 UTC | |
|
Re: Moose stringification overloading isn't working
by Anonymous Monk on Feb 10, 2013 at 07:29 UTC | |
by 7stud (Deacon) on Feb 10, 2013 at 07:32 UTC |