What tye said. Just because you can do something doesn't
mean that it isn't also a really stupid idea to do it. Using map or grep in void context is a sign of someone who has picked up bad habits.
UPDATE
I was asked why talking about modifying the input list
triggered comments about void context from me and tye.
Here is why. The typical bad idiom you see is to use a
grep in void context to
change the input list. Hence the alarm. Note that it is usually a bad idea to modify
the input list when not in void context, but occasionally
it may be natural to do that. For instance the input
list is temporary, and you want to both filter and modify
in an obvious way. Here is an example of a case where it
would fit:
return grep s/^FOR_PRINT://, <FILE>;
In my experience these cases tend to be rare.
UPDATE 2
merlyn is right. I would have to work harder to come
up with a place where modifying the input list makes sense. Given that I am not feeling well, I don't feel like doing that, and given that I think it is a bad idea, I don't think I should bother...
-
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.
|