Ruby IO

Basic Input and Output

print "Enter your name: "
name = gets

Opening and Closing Files

aFile = File.new("testfile", "r")
...
aFile.close

File.open("testfile", "r") do |aFile|
...
end

两者的不同在于前者指定关闭,而后者随代码框关闭。。。| |相当于perl中的$_。由代码上文确定。

Reading and Writing Files

aFile = File.new("testfile")



http://www.ruby-doc.org/docs/ProgrammingRuby/

你可能感兴趣的:(perl,Ruby)