On Jun 23, 2006, at 9:55 AM, Peter Bailey wrote:

> This is part of a script I use that simply ftps a bunch of files  
> over to
> a UNIX server at my company. It does work, but, I keep getting a  
> warning
> message from RUBY about "rb:20:warning: already initialized constant
> BWDFile". The line 20 it's referring to is my line 5 below.
>
> Thanks for any help.
> ---------------------------------------------------------------------- 
> -------------
> ...
> 1 ftp = Net::FTP.open('quark.bna.com') do |ftp|
> 2 ftp.login('xxxxxx','xxxxxxxx')
> 3 ftp.chdir('/xxxxx/xxx/xxd/xxxx')
>
> 4 BWDFiles=Dir.glob("*.{pdf,gif}")
> 5 BWDFiles.each do |BWDFile|
> 6	ftp.putbinaryfile(BWDFile)
> 7	FileUtils.rm(BWDFile)
> 8	end
> 9 end

One of the conventions of the Ruby language is that capitalized  
variable names are considered constants. You can fix your problem by  
changing BWDFiles to bwd_files and BWDFile (which changes each  
iteration therefore it isn't constant) to bwd_file. Ruby only  
CamelCases class names, never variables. If you stick with the  
conventions, other rubyists reading your code will have an easier  
time deciphering it.

> 4 bwd_files=Dir.glob("*.{pdf,gif}")
> 5 bwd_files.each do |bwd_file|
> 6	ftp.putbinaryfile(bwd_file)
> 7	FileUtils.rm(bwd_file)
> 8	end
> 9 end

cr