From: dblack@... Date: 2007-09-16T21:16:39+09:00 Subject: Re: NoMethodError: undefined method `scanf' for main:Object Hi -- On Sun, 16 Sep 2007, Alex Shulgin wrote: > Hi, > > I'm trying to use scanf(), but no luck: > > $ ruby --version > ruby 1.8.6 (2007-06-07 patchlevel 36) [i486-linux] > $ uname -a > Linux zrbite 2.6.21-2-686 #1 SMP Wed Jul 11 03:53:02 UTC 2007 i686 GNU/ > Linux > $ irb > irb(main):001:0> w=scanf("%s") > NoMethodError: undefined method `scanf' for main:Object > from (irb):1 > irb(main):002:0> > > Trying to call $stdin.scanf() does not help either (NoMethodError). > What I'm missing? You have to require it: irb(main):001:0> require 'scanf' => true irb(main):002:0> a = scanf("%s") abc => ["abc"] irb(main):003:0> a => ["abc"] 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)