[ale] [OT] Variation of grep

Jeff Lightner jlightner at water.com
Thu Mar 12 14:49:21 EDT 2009


I'm starting to think Basic isn't enough anymore...

-----Original Message-----
From: ale-bounces at ale.org [mailto:ale-bounces at ale.org] On Behalf Of JK
Sent: Thursday, March 12, 2009 2:29 PM
To: ale at ale.org
Subject: Re: [ale] [OT] Variation of grep

Ed Cashin wrote:
> On Wed, Mar 11, 2009 at 6:27 PM, JK <jknapka at kneuro.net> wrote:
> ...
>> (Bring on the perl one-liners...)
> 
> My perl is rusty.  I can't remember it's equivalent to ruby's "scan".
> 
> ruby -e 'gets(nil).scan(/CUSTOMER.*?\/CUSTOMER/m).each {|i| puts i if
> i =~ /STATE: WA/m }' /tmp/dat
> 
> That works fine unless /tmp/dat is big.  Does your current python
> implementation slurp the whole input into memory like this one-liner?

No.  It uses file.xreadlines(), which creates an iterator that reads
from
the file on demand.

However, I'd be surprised if a similar facility didn't exist in Ruby.
That one-liner is enough to get Ruby into my "next-language-to-learn"
slot. After Haskell, which I'm working on now.

-- 
I do not particularly want to go where the money is -
  it usually does not smell nice there. -- A. Stepanov
_______________________________________________
Ale mailing list
Ale at ale.org
http://mail.ale.org/mailman/listinfo/ale
 
Please consider our environment before printing this e-mail or attachments.
----------------------------------
CONFIDENTIALITY NOTICE: This e-mail may contain privileged or confidential information and is for the sole use of the intended recipient(s). If you are not the intended recipient, any disclosure, copying, distribution, or use of the contents of this information is prohibited and may be unlawful. If you have received this electronic transmission in error, please reply immediately to the sender that you have received the message in error, and delete it. Thank you.
----------------------------------



More information about the Ale mailing list