From: dblack@... Date: 2007-09-16T21:15:51+09:00 Subject: Re: NoMethodError: undefined method `scanf' for main:Object Hi -- On Sun, 16 Sep 2007, Bil Kleb wrote: > Alex Shulgin wrote: >> Hi, > > Hi. > >> Trying to call $stdin.scanf() does not help either (NoMethodError). >> What I'm missing? > > I don't know, but the ri docs sure are sparse for ruby 1.8.6 (2007-03-13): > > $ ri scanf > More than one method matched your request. You can refine > your search by asking for information on one of: > > IO#block_scanf, IO#scanf, Kernel#scanf, String#block_scanf, > String#scanf > > $ ri Kernel.scanf > ----------------------------------------------------------- Kernel#scanf > scanf(fs,&b) > ------------------------------------------------------------------------ > (no description...) > > But the original project examples at > > http://www.rubyhacker.com/code/scanf/ > > might get you going... That version is obsolete; it's best to use the one that ships with Ruby. You have to require it, though -- it's standard library rather than core. require 'scanf' p "abc 123".scanf("%s%d") => ["abc", 123] There's considerable documentation in the source file, but it's not in rdoc form. It's on my to-do list.... David -- * Books: RAILS ROUTING (new! http://www.awprofessional.com/title/0321509242) RUBY FOR RAILS (http://www.manning.com/black) * Ruby/Rails training & consulting: Ruby Power and Light, LLC (http://www.rubypal.com)