ForNext
Only Do What Only You Can Do
181. read entire file into array or string
Hyperpolyglot Interpreted Languages: PHP, Perl, Python, Ruby より (2012.05.08)
VBScript
JScript
Perl
@a = <$f>; $s = do { local $/; <$f> };
PHP
$a = file("/etc/hosts"); $s = file_get_contents("/etc/hosts");
Python
a = f.readlines() s = f.read()
Ruby
a = f.lines.to_a s = f.read