Re: Java v Perl dashing golf

[email protected] (Chris Dolan)
Newsgroups perl.golf
Organization Clotho Advanced Media
Message-ID <[email protected]>
Yanick wrote:
> On Wed, Sep 18, 2002 at 12:09:18AM +1000, [email protected] wrote:
> 
>>I have not seriously tried the 100 meter dash, but this
>>one should be a little faster:
>>
>>#!perl -n
>>/^192\.(?:9|18|29)\./||/(?i:gif|jpg|css) HTTP/ or print
> 
> 
>   /^192\.(?:9|18|29)\./||/(gif|jpg|css|GIF|JPG|CSS) HTTP/ or print
> 
>   is much faster (or so a quick test seems to indicate). On a ad hoc
> test file of 100Megs, this script beats the java program of a few
> seconds (I get 7 seconds for perl, and 9 for java).
> 

Andrew missed the extension separator.  It should be:

/^192\.(?:9|18|29)\./||/\.(gif|jpg|css|GIF|JPG|CSS) HTTP/ or print

Also, "?:" is not really needed.  We don't care about backreferences.
Finally, Andrew incorrectly matches, e.g., ".GiF HTTP" where `/anick's
better reproduces the original code.

Shorter than `/'s:
  -n /^192\.(9|18|29)\.|\.(gif|jpg|css|GIF|JPG|CSS) HTTP/||print

One character longer, but more fun:
  -n $a='gif|jpg|css';/^192\.(9|18|29)\.|\.($a|\U$a) HTTP/||print

[hris
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.