Is it possible (and sensible) to change the value that a Moose object evaluates to ina scalar context. For example if I do
my $object = MyObject->new();
print $object;
Instead of printing something like:
MyObject=HASH(0x1fe9a64)
Can I make it print some other custom string?
Look into the
overloadpragma. I don’t think you can overload scalar context, but try overloading stringification (which is denoted by"",which you must quote becoming the silly looking, quoting using the'""'qoperator make this more readable).