From: Justin Collins Date: 2006-08-19T03:28:06+09:00 Subject: Re: hpricot --------------040900070104030708000405 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit fabsy wrote: > Chris Gehlker skrev: > > >> On Aug 18, 2006, at 10:55 AM, fabsy wrote: >> >> >>> I'ts really strange.. It works in irb but not when im pasting in in a >>> .rb file.. >>> Maby I should re-install it? >>> >> Maybe. It seems to me that if it weren't installed correctly it >> wouldn't work in irb either but I can't think of anything better to try. >> -- >> Vegetarians eat Vegetables, Humanitarians frighten me >> > > Yeah.. re-installed it but i still get the same error.. > > I just pasted: > > require 'rubygems' > require 'hpricot' > require 'open-uri' > > doc = Hpricot(open("http://qwantz.com/")) > (doc/"p/a/img").each do |img| > puts img.attributes['class'] > end > > into a file and tried to run it.. It gave me the > "hej.rb:1: parse error, unexpected tIDENTIFIER, expecting $ > require 'open-uri'" > > But it still works when i paste it directly into irb.. > Why is it saying parse error on line 1 if "require 'open-uri'" is on line 3 of your example? How are you running the file? ruby hej.rb or ./hej.rb ? Also, that's a great comic. -Justin --------------040900070104030708000405--