The
Want module is quite interesting, but seems a little awkward in terms of implementation. Here's an example:
use Want;
sub fooz : lvalue
{
defined ($foo_new)?
$foo_new
: (want('LVALUE','ASSIGN')?
$foo_new = $foo
: $foo);
}
Internally, there is a function from the Wait.xs component called 'want_lvalue', which is really all I need. If it were assigned a default parameter value (it relates to stack depth) then it could be used like so:
use Want;
sub fooz : lvalue
{
defined ($foo_new)?
$foo_new
: want_lvalue?
$foo_new = $foo
: $foo);
}
This does seem to be a lot neater, though not currently implemented.
It just goes to show that
CPAN has a module for every occasion. I wouldn't be surprised to see
Cheese::Grater.
Thanks for the tip. It's exactly what I was looking for.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.