See Want.pm

djberg96 on 2002-03-14T19:30:37

Ok, a conversation came up in pdcawley's journal, and I thought I should share something with y'all as most people don't seem to know about it.

Basically, the topic centered around whether or not to always return $self (for method chaining) or a value (for, say, an lvalue).

With Want, by Robin Houston (robin), you can distinguish based on calling context. So, for example, you can tell the difference between these:

$obj->method1;

$obj->method1->method2;

$val = $obj->method;

myFunc($obj->method);

Want can do much more than this (eg rvalue subs, etc), but I find the "want('OBJECT')" call to be the most useful. :)

Enjoy!