Gaal Yahas wrote:

> Join the Useless Use of cat Crazies! Rewrite that as
> 
>         awk -F: '($3 > 100) {print $1}' < /etc/passwd > /etc/allusers
> 
> (note field #2 is the password)
> 
> Err. Waitaminute!!! I'm supposed be advocating Perl:
> 
>         perl -lne '/^(.*?):.*?:(\d+)/&&$2>100&&print$1' /etc/passwd
>                 > /etc/allusers
> 
> Darn. Longer :-|
> 
> Well, as Larry Wall put it, "AWK has to be better for something :-)"

As long as we're quoting Perl.gods, how about this one from Tom
Christiansen's `Csh Programming Considered Harmful':

        Tchrist's personal rule of thumb is that if it's the size
        that fits in a Makefile, it gets written in the Bourne shell,
        but anything bigger gets written in Perl.

There's a reason for that; for small tasks like this, using something
like awk for is not only clearer and more concise, it's also much
more faster than using a monster like Perl.

        adam ~ ? wc -l passwd
          29952 passwd
        adam ~ ? awk -F: '($3 > 100) {print $1}' < passwd > /dev/null
        wall=0:00.47 (u=0.460 sys=0.010) cpu=100.0% space=0 (shared=0 unshared=0) 
maxmem=0 pgflt=134(30) ctx=0 (waits=0)
        adam ~ ? perl -lne '/^(.*?):.*?:(\d+)/&&$2>100&&print$1' < passwd > /dev/null
        wall=0:01.36 (u=1.360 sys=0.000) cpu=100.0% space=0 (shared=0 unshared=0) 
maxmem=0 pgflt=236(37) ctx=0 (waits=0)
        adam ~ ? perl -lanF: -e'$F[2]>100&&print$F[0]' < passwd > /dev/null
        wall=0:01.85 (u=1.830 sys=0.030) cpu=100.5% space=0 (shared=0 unshared=0) 
maxmem=0 pgflt=232(36) ctx=0 (waits=0)
        adam ~ ? perl --version

        This is perl, version 5.005_03 built for i386-linux

        Copyright 1987-1999, Larry Wall

        Perl may be copied only under the terms of either the Artistic License or the
        GNU General Public License, which may be found in the Perl 5.0 source kit.

        Complete documentation for Perl, including FAQ lists, should be found on
        this system using `man perl' or `perldoc perl'.  If you have access to the
        Internet, point your browser at http://www.perl.com/, the Perl Home Page.

=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to