I think in a case like this, it depends on what the code is meant for. If it's just to play around and to find a faster solution for yourself, using the Schwartzian Transform might be a nice idea. But if it's for a production environment, your code (IMHO) might be better suited since it is more clear. In this case, the comparison is cheap enough to warrant wasting more cycles in favour of readability.
Remember, there will always be a programmer after you who has to read your code. And only in an ideal world is (s)he familiar with advanced Perl techniques.
-
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.
|