From: Robert Klemme Date: 2010-05-14T01:35:11+09:00 Subject: Re: reading file after a particular line in file On 13.05.2010 16:34, Une Bévue wrote: > Robert Klemme wrote: > >> There's also the flip flop operator: >> >> File.foreach "myfile" do |line| >> if /pattern/ =~ line .. false >> puts line >> end >> end >> >> The trick I am using is that the FF operator starts to return true if >> the first expression returns true and stays true until the last >> expression returns true - in this case never since you want to read >> until the end of the file. > > coud that trick be used for start and stop tags ? like : > > File.foreach "myfile" do |line| > if / puts line > end > end > > if true, that's clever ! Yes, that could be done. However, I would not use this for languages from the SGML family (XML, HTML) because there are no guarantees as to how many tags you'll find on a single line of text. There are better tools do deal with that (REXML, Nokogiri...). Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/