From: Paul Lutus Date: 2006-10-22T12:25:11+09:00 Subject: Re: What is wrong with my code Li Chen wrote: > Hi folks, > > I write two srcipts to check files in a given directory. Version 1 uses > regular expression and works but I cann't find the size for each file. > Version 2 uses Ruby built-in File.file? method but it doesn't work at > all. Explain. What error messages did you see? You need to provide more information. > I wonder what is going on with my scripts? > > Thank you, > > Li > > #######Version 1: > > path='c:\path\to\folder' Don't use backslashes like this. Use forward slashes to avoid problems in interpretation. Ruby will know what to do. > Dir.open(path).each do |file| > if file=~/(\w+|d+).(\d{3,})/ > puts file > puts File.size(file)# this line doesn't work "Doesn't work"? Please tell us what error message you saw. Maybe the "file" was a directory? -- Paul Lutus http://www.arachnoid.com