$obj->thing(15000, 20000) =~ s[something][else]g;
might be easier to read as:
$spreadsheet->cell('C3', 'D4') =~ s[something][else]g;
There has to be a clean, and I mean absolutely clean, way of doing this - which P6 is either giving to us, or will get us very close to. What we have in P5 is not even close:
# current lvalue sub:
(my $val = $spreadsheet->cell('C3', 'D4')) =~ s[something][else]g;
$spreadsheet->cell('C3', 'D4') = $val;
$spreadsheet->recalc() if $spreadsheet->autorecalc();
# without lvalue sub:
(my $val = $spreadsheet->cell('C3', 'D4')) =~ s[something][else]g;
$spreadsheet->cell('C3', 'D4', $val);
A world of difference syntactically in the problem domains where this makes sense. With the current lvalue sub, you can't hook in after the assignment to do things (such as validation, or, as above, recalculating the sheet). Without the lvalue sub, we can do this, but syntactically it's a bit more awkward. |