From: Robert Klemme Date: 2004-10-07T22:59:47+09:00 Subject: Re: Index of multiple similar strings "Milo Thurston" schrieb im Newsbeitrag news:ck3grg$8bv$1@news.ox.ac.uk... > ts wrote: > > R> ??? Care to explain? > > You create a String object for each call, you don't have this problem with > > $~.begin(0) > > That would explain it. Some of the strings I'm looking at are several MB > in size. I've been writing out the data to disk and flushing stdout, but > $` seemed to leave each complete sequence in memory, causing it to run > out rather rapidly. Yes, that's the reason. I haven't though about this, but as you can see each reference to $` creates a new string instance: 15:55:29 [robert]: ruby -e '"f".scan(/./) { 5.times{ puts $`.id } }' 134690392 134690368 134690344 134690320 134690296 15:55:58 [robert]: Kind regards robert