[ create a new paste ] login | about

Link: http://codepad.org/CC98XPaa    [ raw code | output | fork ]

Ruby, pasted on Aug 27:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
def wc(file_name)
	info_arr = []
	arr = IO.readlines(file_name)
	info_arr << arr.length
	str = arr.join(" ")
	chr_find_arr = str.gsub(" ","").split(//).length
	info_arr << chr_find_arr - arr.length
	words_find_arr = str.split(" ").length
	info_arr << words_find_arr
	return info_arr
end


puts wc("test.txt")


Output:
1
2
3
Line 3:in `readlines': No such file or directory - test.txt (Errno::ENOENT)
	from t.rb:3:in `wc'
	from t.rb:14


Create a new paste based on this one


Comments: