in reply to Can I ask Perl if an object will stringify?
Hi,
Methinks you are trying to break the language itself: perl stringifies everything on demand (in string context). The "stringification" operator purpose is to provide something meaningful, and not to be some marker "it stringifies to to something meaningful".
I think you can use something like UNIVERSAL::can to check pretense of method like "to_my_string". If the passed object don't have that method, that means that something is wrong, and die could be better then warn.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Can I ask Perl if an object will stringify?
by haukex (Archbishop) on May 25, 2015 at 10:12 UTC |