[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] IP address regex golf- (broken smtp)



 me, myself and i write -- (im not sure if this already got sent because my mail client kinda is lame..so
apology if you get this twice)
There is a trait in the Perl community to
obsfucate wildly at every possible  chance, and while this is fun it can also
be a way to breed bad coding practice.  Personally I'm a big fan of a good
regular expression challenge, and this ip  checking problem instinctivly begs
to be tackled with a nice long regexp.  I decided to try it another way, without
regular expressions and here it is  for(split/\./){++$x if($_<256)}
if($x==4){}
which takes it down to 43. A partially valid reason to use a regexp is
that it is faster as a simple benchmark shows.
Benchmark: timing 100000 iterations of his, mine...
his:  3 wallclock secs ( 2.45 usr +  0.00 sys =  2.45 CPU)
mine:  4 wallclock secs ( 3.81 usr +  0.00 sys =  3.81 CPU)
Then we are getting into the philosophy of readibilty(maintainability)/speed
idealogical tradeoff. Something I read and go by from "Programming
Pearls"-J.Bentley is the quote on improper code tuning, though the book is at
work the quote is to the effect that improper code optimization is the source
of all Programming evils.. so what am I saying here? basically as coders there
needs to be a judgement call on when being tricky is smarter then being more
straightforward.. and whether some of these little games we play on FWP
are really "good clean fun"....hummina hummina.. 

michael salmon
> 
>   > On Sun, 07 May 2000, you
> wrote: > > On Fri, Apr 28, 2000 at 11:24:27PM -0500, Keith Calvert Ivey wrote:
> > > 
> > > > That doesn't work.  Try 512.1.1.1, for example, or anything 
> > > > else that has a number greater than 256 without the 256 bit 
> > > > set.  Try this:
> > > 
> > > You have to negate the 255:
> > > 
> > >    /(\d+)\.(\d+)\.(\d+)\.(\d+)/ && !((1 | $1 | $2 | $3 | $4) & ~255
> > > 
> > > should do the trick.
> > > 
> > >   Holger
> > > 
> > > 
> > > -- 
> > > + GnuPG || PGP key -> finger eitz@jonathan.weh.rwth-aachen.de +
> > > +++ Debian GNU/Linux <octavian@debian.org> +++ ICQ: 2882018 +++
> > > 
> > > ==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
> > > ==== Send email to <fwp-request@technofile.org> with message _body_
> > > ====   unsubscribe
> > -- 
> -- 

-- 
http://www.6x4.org
"The 3 great virtues of a programmer:
  Laziness,Impatience, and hubris.
	--Larry Wall

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe