my @L = map {
fix($_->[4]);
fix($_->[8]);
[ @$_[0,2,3,6,4,8] ]
} grep {
@$_ == 10 and
($_->[7] eq 'IP') and ($_->[9] eq 'local')
} map {
[ split ]
} <F>;
i think map in void context is just fine. if i decided to place my data in a hash for later lookup i just might do so at the end of the first map (instead of returning an array of arrays). i'm sure i wouldn't try and re-craft the code to use a for just to appease.
much in the same way i use the 'useless' cat in my shell pipelines.
$ cat foo.txt | fgrep blah
it's much easier to decide to add more files to the cat (try that with <file ). or to replace the cat with another command that generates the data. why on earth would i continuously rewrite my commands when i can up-arrow and add easily to the beginning?
$ fgrep blah <foo.txt | consolidate | dump
$ preproc <foo.txt | fgrep blah | consolidate | dump
$ additional <foo.txt | preproc | fgrep blah | consolidate | dump
# vs
$ cat foo.txt | fgrep blah | consolidate | dump
$ cat foo.txt | preproc | fgrep blah | consolidate | dump
$ cat foo.txt bar.txt | additional | preproc | fgrep blah | consolidat
+e | dump
$ real_stream | additional | preproc | fgrep blah | consolidate | dump
i'll keep my useless cat and my map in void context thank you much. they're my artifacts of iterative development.
-
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.