in reply to Mixed lvalue/rvalue sub function
If you want this kind of interface, I'd recommend you use overload and present the object as a hash. Have a look at Make an inside-out object look hash-based using overload. for an example of what I'm talking about. You can have code that looks like this:
$obj->{header}{'My Header'} = $value; if ( $obj->{header}{'My Header'} eq 'value' ) # ...
...and behind the scenes it can call whatever instance method you want.
That said, this is all a bit more than is really necessary. I wouldn't put this kind of interface on any new code, but it's not horrific enough for me to want to remove it from working code either.
|
|---|