Moving files

pll at lanminds.com pll at lanminds.com
Mon Jan 6 12:50:02 EST 2003


In a message dated: Mon, 06 Jan 2003 12:06:23 EST
Derek Martin said:

>I disagree, in large part, though I've definitely seen worse. I find
>the syntax of the grep and map to be pretty cryptic,

How is it cryptic?

	grep BLOCK LIST
               Evaluates the BLOCK or EXPR for each element of
               LIST (locally setting $_ to each element) and
               returns the list value consisting of those ele­
               ments for which the expression evaluated to true.

My grep was pretty damn simple:

        grep { ! /^\./ && -f $_ } readdir(DIR);

          ^    ^^^^^^^^^^^^^^^^        ^
          |            |               |
        grep         BLOCK           LIST

And my map was the same:

       map BLOCK LIST
               Evaluates the BLOCK or EXPR for each element of
               LIST (locally setting $_ to each element) and
               returns the list value composed of the results of
               each such evaluation.

       map {($n = $_)=~ s/\s+/_/g; rename ($_, $n)} @f;
        ^   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^   ^
        |                     |                      |
       map                  BLOCK                   LIST

The syntax is identical for both map and grep (they do slightly 
different things, but not that different).  Both take a block or an 
expression an operated on some list of "things".

Now, I will grant that both can be used in quite esoteric and bizarre 
ways to achieve side-effect results, but that's not so different than 
a lot of C code which does the same.

I will also grant you that the regexps lend to some amount of 
unreadability, however, these shouldn't pose a problem with someone 
familiar with sed, awk, and *grep.
-- 

Seeya,
Paul
--
Key fingerprint = 1660 FECC 5D21 D286 F853  E808 BB07 9239 53F1 28EE

	It may look like I'm just sitting here doing nothing,
   but I'm really actively waiting for all my problems to go away.

	 If you're not having fun, you're not doing it right!





More information about the gnhlug-discuss mailing list