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
