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

Re: [FWP] president



Peter Scott <Peter@PSDT.com> wrote:

> perl -MLWP::Simple 
> -le'@a[0,1]=get("http://cnn.com")=~/([\d,]{9})/g;$"="-";s/,//g
> for@a;print eval"@a"'

The $" stuff may be fun, but it's not good for golf.  The 
straightforward way is shorter:

  perl -MLWP::Simple
  -le'@a[0,1]=get("http://cnn.com")=~/([\d,]{9})/g;s/,//g
  for@a;print$a[0]-$a[1]'

Also, the [0,1] is unnecessary, and things can be changed around
to save more strokes (I used y... instead of s/// for fun and 
efficiency):

  perl -MLWP::Simple
  -le"y.,..dfor@a=get('http://cnn.com')=~/([\d,]{9})/g;print$a[0]-$a[1]"


-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC

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