Peter Bailey wrote:
> Nobuyoshi Nakada wrote:
>> 
>>     if /%!PS-Adobe/ =~ IO.open(file) {|f| f.gets}
>>       File.rename(file, file + ".eps")
>>     end
> 
> Yes, I'm on Windows. And, yes, it makes sense that it won't let me do it 
> because the file is, apparently, still open. But, I guess I'm stumped as 
> to how I can open the file to check that first line, match against that 
> first line, close the file, and then be able to rename the filename of 
> that particular file. Once the file is closed I really can't do anything 
> more inside that same if-end loop, can I?
> 
> -Peter


This line:

>>     if /%!PS-Adobe/ =~ IO.open(file) {|f| f.gets}    

opens the file, gets the first line, closes the file, and checks the 
line against the regex for a match.  If there is a match, this code 
executes:

>>       File.rename(file, file + ".eps")
>>     end

That line renames the file.

> But, I guess I'm stumped as 
> to how I can open the file to check that first line, match against that 
> first line, close the file, and then be able to rename the filename of 
> that particular file. Once the file is closed I really can't do anything 
> more inside that same if-end loop, can I?

What more do you want to do?

-- 
Posted via http://www.ruby-forum.com/.