I personally believe and hope that this node can be considered as an "ever active one" so I won't clutter Meditations with this "new" idea of mine like I've been tempted to do, but post it as a followup here...
Well, here's my modest proposal re join: if the first argument passed to it is a reference, then it should not stringify it (which is unlikely to ever having been useful, and thus should not break any backwards compatibility) but
- if it is a hashref of the form { first => [LIST], then => [LIST] } then it should join the first items on the 'first' list and the remaining ones on the 'then' one, cyclically; for maximum dwimmery, if keys other then these (or better chosen ones, but these sound reasonable) are given, the first two in alphabetic order (which does make sense) would be used; if any key is missing, then the corresponding LIST would be treated as empty;
- if it is an arrayref $arr, then it would behave as if it were {then => $arr};
- if it is a subref then the subref would be called each time, with no arguments and its return value would be used to join on;
- if it is a scalar or glob ref, then I can't imagine any particularly good semantics; and if it is a blessed ref, then... I was thinking of making it check for especially named methods like 'action' (corresponding to the sub case above, and possibly taking precedence,) 'first' and 'then' but probably it would be better to just leave the object stringify the way it prefers and not deviate from the current behaviour.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|